以下是一张图表。如何反转Y轴,使其从上到下读取"a b"而不是"b a",同时保持X轴不变? 代码: library(ggplot2) levels = ordered(c('a', 'b')) data = data.frame(x=ordered(c('a', 'a', 'b', 'b'), levels=levels), y=ordered(c('a', 'b', 'a', 'b'), levels=levels), prob=c(0.3, 0.7, 0.4, 0.6)) ggplot(data, aes(x, y)) + geom_tile(aes(fill=prob))
ggplot(data, aes(x, forcats::fct_rev(y))) + geom_tile(aes(fill=prob))
- Axeman