I am trying to change the colour bars using ggplot2 on a bar graph with frequency data. However, my plot is still appearing in greyscale.
Data (400 observations that take values between 1 to 5) and code:
library(ggplot2)
library(RColorBrewer)
# Sample data
complete_data <- data.frame(education = sample(1:5, 400, replace = TRUE))
ggplot(complete_data, aes(x=education)) +
geom_bar(stat="count") +
scale_x_discrete(labels=c("1" = "Level 1", "2" = "Level 2","3" = "Level 3","4" = "Level 4")) +
geom_point(aes(color = education)) +
scale_fill_brewer(palette = "PuBu")
I'm getting the following error:
Error in
check_required_aesthetics()
: ! geom_point requires the following missing aesthetics: y Runrlang::last_error()
to see where the error occurred.
What am I doing wrong? I also want to make the background white but that doesn't seem to work either