Search code examples
rggally

changing a color s a ggally ggparcoord plot in r


ggparcoord(data = df, columns = 1:4, mapping=aes(color=as.factor(Species)))+
  scale_color_discrete("Species",labels=levels(df$Species))

How do I change the standard colors of this plot to stesoa=black, versicolor=green, and virginica=mageanta?


Solution

  • You can use scale_color_manual() to set custom colors:

    ggparcoord(df,
               columns = 1:4,
               mapping = aes(color = as.factor(Species))) +
      scale_color_manual("Species",
                         values = c("black", "green", "magenta"),
                         labels = levels(df$Species))
    

    custom colors