How to reverse legend (labels and color) so high value starts downstairs?

后端 未结 3 1625
礼貌的吻别
礼貌的吻别 2020-12-09 16:19

whats the best way to invert the legend label order so the 7 is down and the 1 is upstairs?

\"ggplot

3条回答
  •  一整个雨季
    2020-12-09 17:12

    If you're putting it in numeric and it's a continuous scale, you're better off with scale_fill_continuous(trans = 'reverse') or scale_colour_continuous. Using your code, this would give:

    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")+
        scale_fill_continuous(trans = 'reverse')
    

提交回复
热议问题