plotting the whole data within each facet using facet_wrap and ggplot2

前端 未结 2 1345
情话喂你
情话喂你 2020-12-16 04:23

I am trying to plot line graphs for and facet_wrap for each dataset. What I would love to have is in light grey, transparent or something, all datasets in the b

2条回答
  •  一个人的身影
    2020-12-16 05:22

    Here's another approach:

    First add a new column identical to id:

    df$id2 <- df$id
    

    Then add another geom_line based on the df without the original id column:

    ggplot(df, aes(x,y, group=id)) + 
      geom_line(data=df[,2:4], aes(x=x, y=y, group=id2), colour="grey") +
      geom_line() + 
      facet_wrap(~ id)
    

提交回复
热议问题