ggplot group by one categorical variable and color by a second one

前端 未结 2 1775
长发绾君心
长发绾君心 2020-12-28 08:05

Basically I\'d like to create the first plot shown below in R using ggplot, but with both objects on the same graph (no facet wrapping).

Consider a minimal example

2条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-28 08:39

    You could paste rep and variable a group:

    ggplot(dat) + geom_line(aes(x, value, group = paste(variable, rep), color = variable), 
                        alpha = 0.3) 
    

提交回复
热议问题