如何反转图例(标签和颜色),使高价值从底部开始? [英] How to reverse legend (labels and color) so high value starts at bottom?
本文介绍了如何反转图例(标签和颜色),使高价值从底部开始?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
颠倒图例标签顺序的最佳方法是什么,以使7朝下而1朝上?
whats the best way to invert the legend label order so the 7 is down and the 1 is upstairs?
df$day <- as.numeric(df3$day)
blues <- colorRampPalette(c('#132B43', '#56B1F7'))
p4 <-
ggplot(subset(df,feedback==1&stp>20), aes(x=correct, fill=day, colour=day)) +
geom_histogram(colour="black", binwidth=10) +
facet_grid(day ~ .) +
ggtitle("Over-pronation histogram") +
ylab("Count (150s period)") +
xlab("% Steps in over-pronation") +guide_legend(reverse = false)
推荐答案
您的代码很奇怪,用 false
代替了 FALSE
,并且错误地放置了 guide_legend
.正确的用法是(@Harpal对此提供了提示):
Your code is quite strange, with false
instead of FALSE
and incorrectly placed guide_legend
. The correct usage is (@Harpal gives a hint on that):
ggplot(data.frame(x=1:4, y=4:1, col=factor(1:4)), aes(x=x, y=y, col=col)) +
geom_point(size=10)
ggplot(data.frame(x=1:4, y=4:1, col=factor(1:4)), aes(x=x, y=y, col=col)) +
geom_point(size=10) + guides(colour = guide_legend(reverse=T))
这篇关于如何反转图例(标签和颜色),使高价值从底部开始?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文