R language changes the color of ggplot2 Boxplot

library(ggplot2)

ch <- ggplot(chickwts,aes(x=feed,y=weight,fill=feed))+
  geom_boxplot()

ch

# Assign custom color
ch+scale_fill_manual(values=c("#999999",
                              "purple",
                              "#33FFFF",
                              "red",
                              "green",
                              "brown"))

# Assign brewer color
ch+scale_fill_brewer(palette="Dark2")

insert image description here

ch+scale_fill_brewer(palette="Set1")

insert image description here

ch+scale_fill_brewer(palette="Set2")

insert image description here

ch+scale_fill_brewer(palette="Set3")

insert image description here

ch+scale_fill_brewer(palette="Paired")

insert image description here

ch+scale_fill_brewer(palette="Blues")

insert image description here

ch+scale_fill_brewer(palette="Greens")

insert image description here

ch+scale_fill_brewer(palette="PiYG")

insert image description here

ch+scale_fill_brewer(palette="BrBG")

insert image description here

ch+scale_fill_brewer(palette="PRGn")

insert image description here

ch+scale_fill_brewer(palette="PuOr")

insert image description here

ch+scale_fill_brewer(palette="Reds")

insert image description here

ch+scale_fill_brewer(palette="Oranges")

insert image description here

ch+scale_fill_brewer(palette="Purples")

insert image description here

ch+scale_fill_brewer(palette="PuRd")

insert image description here

ch+scale_fill_brewer(palette="PuBuGn")

insert image description here

ch+scale_fill_brewer(palette="Greys")

insert image description here

ch+scale_fill_brewer(palette="BuPu")

insert image description here

ch+scale_fill_brewer(palette="GnBu")

insert image description here
Development tool: RStudio 2023.06.1 Build 524 © 2009-2023 Posit Software, PBC
WeChat Alt+A screen capture tool
Reference: https://geek-docs.com/r-language/r-tutorials/g_change-color-of- ggplot2-boxplot-in-r.html

Guess you like

Origin blog.csdn.net/m0_38127487/article/details/131902835