Sorry if my question is somehow confusing, don't hesitate to edit it.
I'm comparing 2 sets of data and I'm now creating plots.
On some plots, I can show both groups and ggplot automatically add some pretty colors, in my case red for the first group, and blue for the second one.
My problem is that on other plots, I have to show either one group or the other, and so the color is always red.
How can I manually ask ggplot to fill my plot with the second color of the theme ?
Here is some dummy code if you like :
df <- data.frame(f1=factor(rbinom(100, 1, 0.45), label=c("m","w")),
f2=factor(rbinom(100, 1, 0.45), label=c("young","old")),
boxthis=rnorm(100))
#both groups on the graph, 2 colors (red and blue) :
ggplot(aes(y = boxthis, x = f2, fill = f1), data = df) + geom_boxplot()
#each group on one graph, both the same color (and I'd like one red and one blue)
ggplot(aes(y = boxthis, x = f2, fill = "m"), data = df) + geom_boxplot()
ggplot(aes(y = boxthis, x = f2, fill = "w"), data = df) + geom_boxplot()
#I know the grouping is incorrect, this is just an example where I keep the same df
ggplot(aes(y = boxthis, x = f2, fill = "m"), data = df) + geom_boxplot(fill = '#F8766D')
ggplot(aes(y = boxthis, x = f2, fill = "w"), data = df) + geom_boxplot(fill = '#00BFC4')
. – S Rivero