How to set the colors in a ggplot2 boxplot in the R programming language. More details: [ Ссылка ]
R code of this video:
set.seed(29384732) # Create example data
data <- data.frame(value = rnorm(100),
group = letters[1:5])
install.packages("ggplot2") # Install & load ggplot2 package
library("ggplot2")
ggplot(data, aes(x = group, y = value)) + # ggplot2 boxplot without colors
geom_boxplot()
ggplot(data, aes(x = group, y = value, col = group)) + # Change color of borders
geom_boxplot()
ggplot(data, aes(x = group, y = value, fill = group)) + # Change filling color
geom_boxplot()
ggplot(data, aes(x = group, y = value, fill = group)) + # Manually specified filling color
geom_boxplot() +
scale_fill_manual(breaks = data$group,
values = c("#1b98e0", "#353436", "yellow", "red", "green"))
Follow me on Social Media:
Facebook: [ Ссылка ]
LinkedIn: [ Ссылка ]
Twitter: [ Ссылка ]
Ещё видео!