ggplot: colour points by groups based on user defined colours

后端 未结 3 1923
庸人自扰
庸人自扰 2020-12-01 13:05

I am trying to define the colours of groups of points plotted in ggplot. I adapted code from this post:

Color ggplot points based on defined color codes

but

3条回答
  •  一个人的身影
    2020-12-01 13:29

    It works if you use unique and as.character:

    ggplot(data = df, aes(col, D, colour = zone))+ 
      geom_point() +
      scale_colour_manual(breaks = df$zone, 
                          values = unique(as.character(df$color.codes)))
    

    enter image description here

提交回复
热议问题