I am struggling with how to manually change the color of the stripes in ggplot2. Strange, but I can make it work using more complex formats requiring legends, using scale_fill_manualand installing values, labelsetc. But when creating a simpler diagram that does not require a legend, I may not seem to make it work. The following is an example of a data frame, the steps that I used dplyrto get interest, and how I think it should work in ggplot2. I just want to manually change the panel colors to red, seagreen3 and gray.
Any help would be appreciated. I am also curious to know the various methods that are used to quickly calculate interest. I use pipelining with dplyr, but if it was great to see other ways of writing code.
library(dplyr)
library(ggplot2)
Service <- c("Satisfied", "Dissatisfied", "Neutral", "Satisfied", "Neutral")
Service2 <- c("Dissatisfied", "Dissatisfied", "Neutral", "Satisfied", "Satisfied")
Services <- data.frame(Service, Service2)
ServicesProp <- Services %>%
select(Service) %>% group_by(Service) %>%
summarise(count=n()) %>%
mutate(percent = count / sum(count))
ggplot(ServicesProp, aes(x = Service, y = percent)) +
geom_bar(stat = "identity", position = "dodge") +
scale_fill_manual(values = c("red", "seagreen3", "grey"))
source
share