I have the following code:
Figure1plot <- ggplot(Figure1data, aes(x = ngirls, y = nowtot, fill = party, col = party))
+ stat_summary(fun = mean, geom = "bar", inherit.aes = TRUE)
+ facet_grid(rows = vars(totchi), cols = vars(party), margins = "party")
+ scale_fill_manual(values = c("Democrat" = "blue", "Republican" = "red", "(all)" = "black"),
breaks = c("Democrat", "Republican", "(all)"), aesthetics = c("color", "fill"))
+ xlab("Number of female children")
+ ylab("Mean NOW score")
which produces the follwing bar chart:
How do I apply different shadings for the different values for the x-variable (number of female children), so that the bars have different shadings of blue, red, and black? I've tried changing the x and y variables into factors and integers, without success.
Additionally, how do I add another legend for the number of daughters?
Many thanks in advance!