ggplot2: Bring one line to the front, but save the colors

前端 未结 4 1046
忘了有多久
忘了有多久 2021-01-04 06:32

Consider the following code:

library(ggplot2)
foo <- data.frame(x=1:10,A=1:10,B=10:1)
ggplot(melt(foo,id.vars=\"x\"),aes(x,value,color=variable))+geom_lin         


        
4条回答
  •  天涯浪人
    2021-01-04 07:18

    The order of your A,B inside data.frame(x=1:10,A=1:10,B=10:1) is causing this layering issue because it is drawing A (1:10) first.

    If you use data.frame(x=1:10,A=10:1,B=1:10) is will put the ascending line on top (since B is drawn last).

提交回复
热议问题