How to modify the fill and border color of a ggplot2 plot in the R programming language. More details: https://statisticsglobe.com/change-fi...
R code of this video:
data <- data.frame(x = 1:6, # Create example data
y = c(3, 1, 5, 4, 2, 4),
group = factor(letters[1:3]))
install.packages("ggplot2") # Install & load ggplot2 package
library("ggplot2")
ggp <- ggplot(data, # Create ggplot2 scatterplot
aes(x, y,
color = group,
fill = group)) +
geom_point(size = 7,
shape = 21,
stroke = 3)
ggp # Draw ggplot2 scatterplot
ggp + # Change fill & border color
scale_fill_manual(values = c("a" = "yellow",
"b" = "#1b98e0",
"c" = "#353436")) +
scale_color_manual(values = c("a" = "#353436",
"b" = "yellow",
"c" = "#1b98e0"))
Follow me on Social Media:
Facebook: / statisticsglobecom
LinkedIn: / statisticsglobe
Twitter: / joachimschork