I'm not sure, but I think I recall that ggplot2 used this color scheme by default for plots, if no color aesthetics was specified. However, later versions of ggplot now use a single color for simple frequencies (without grouping/colour aesthetics):
library(ggplot2)
library(sjmisc)
data(efc)
ggplot(efc, aes(e42dep)) + geom_bar()
That's why the image you posted has different colors, while now sjp.frq
prints bars in one color only. Since you don't have a grouping aesthetics for simple frequency bars, you can't provide different colors for each geom / bar in sjp.frq
. In this case, you have to find your own solution and add a group-aes, like:
ggplot(efc, aes(e42dep, fill = to_label(e42dep))) +
geom_bar() +
labs(y = NULL, x = get_label(efc$e42dep), fill = get_label(efc$e42dep)) +
scale_x_continuous(breaks = c(1:4), labels = get_labels(efc$e42dep))
However, to me it does not make much sense to give each bar a seperate color and provide axis labels. Using a legend instead of axis labels (drop axis labels) would work, but this makes the graph less intuitive, because you have to switch between legend and bars to find out which bar represents which category. For simple frequency plots, this is unnecessary complexity.