Combining geom_point and geom_line with position_jitterdodge for two grouping factors

后端 未结 2 1735
无人共我
无人共我 2020-12-11 19:26

I\'ve tried several suggestions based on several posts on here, as well as reading through the ggplot2 documentation, but this question is slightly different, and I haven\'t

2条回答
  •  情话喂你
    2020-12-11 20:00

    You can use the interaction between d and b:

    p <- ggplot(temp, aes(x=interaction(d, b), y=c, fill=d, colour=d))+ theme_classic()+
        geom_point()
    p + geom_line(aes(group=a),colour=1)
    

    with correct x axis. Convert the x to numeric and set new labels

    p <- ggplot(temp, aes(x=as.numeric(interaction(d,b)), y=c, fill=d, colour=d))+ theme_classic()+
         geom_point()
    p <- p + geom_line(aes(group=a),colour=1)
    p +  scale_x_continuous(breaks = c(1.5,3.5,5.5), labels = levels(temp$b))
    

提交回复
热议问题