如何将ggplot2图例移动到绘图底部并将其水平旋转?
Sample code:
library(reshape2) # for melt
df <- melt(outer(1:4, 1:4), varnames = c("X1", "X2"))
p1 <- ggplot(df, aes(X1, X2)) + geom_tile(aes(fill = value))
p1 + scale_fill_continuous(guide = guide_legend())
Desired (approximate) outcome:
2 回答
如果要移动图例的位置,请使用以下代码:
这应该会给你想要的结果 .
两个不完美的选项,不能完全满足您的要求,但非常接近(至少会将颜色放在一起)
由reprex包创建于2019-02-28(v0.2.1)