ggplot: colour points by groups based on user defined colours

后端 未结 3 1919
庸人自扰
庸人自扰 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:30

    Sven beat me by a few secs, but slightly different:

    df.unique <- unique(df[, c("zone", "color.names")])
    p + scale_colour_manual(breaks = df.unique$zone, values = as.character(df.unique$color.names))
    

提交回复
热议问题