ggplot2: How to specify multiple fill colors for points that are connected by lines of different colors

后端 未结 1 1120
Happy的楠姐
Happy的楠姐 2020-11-29 09:08

I am new to ggplot2. I would like to create a line plot that has points on them where the points are filled with different colors than the lines (see the plot b

相关标签:
1条回答
  • 2020-11-29 09:36

    scale_fill_manual(), scale_shape_manual() and scale_colour_manual() can be used only if you have set fill=, shape= or colour= inside the aes().

    To change colour just for the points you should add colour=group inside geom_point() call.

      ggplot(data, aes(x=iv, y=dv, group=group,shape=group)) + 
        geom_line() + geom_point(aes(colour=group)) +
        scale_shape_manual(values=c(19,20,21))+
        scale_colour_manual(values=c("blue", "red","gray"))
    

    enter image description here

    0 讨论(0)
提交回复
热议问题