ggerrorplot: how can I change the colors on the Plot?

Viewed 45

enter image description here

Is it possible to give every variable a different color and how?

I would like to keep the legend.

Please note that it is made with ggerrorplot function.

1 Answers

You can use a different palette in your ggerrorplot function. I will use the ToothGrowth dataset as an example:

the color palette to be used for coloring or filling by groups. Allowed values include "grey" for grey color palettes; brewer palettes e.g. "RdBu", "Blues", ...; or custom color palette e.g. c("blue", "red"); and scientific journal palettes from ggsci R package, e.g.: "npg", "aaas", "lancet", "jco", "ucscgb", "uchicago", "simpsons" and "rickandmorty".

For example use palette="Paired" for blue color:

df<- ToothGrowth

library(ggpubr)
ggerrorplot(df, x = "dose", y = "len",
            color = "supp", palette = "Paired",
            error.plot = "pointrange",
            position = position_dodge(0.5))

Output:

enter image description here

Or palette="npg":

enter image description here

Related