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

后端 未结 3 1627
礼貌的吻别
礼貌的吻别 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条回答
  •  萌比男神i
    2020-12-09 17:14

    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))
    

    enter image description here enter image description here

提交回复
热议问题