I am plotting a bar and line chart using a background theme from ggthemes. My variables are grouped by an ordered factor that I set. When I don't use the theme, the factors order the way I want them. But when I add a ggtheme, the order for the line changes, as can be seen in the legend. Why is this happening and how do I fix it?
Example code:
testCount %>%
ggplot(aes(x = tests)) +
theme_solarized_2(light = F) + scale_colour_solarized('blue') +
geom_bar(aes(y = ..prop.., fill = BandType), position = "dodge") +
stat_ecdf(aes(color = BandType), size = 1) +
scale_x_continuous(breaks = seq(0, 18, 1)) +
scale_y_continuous(breaks = seq(0, 1, 0.1), limits = c(0, 1), labels = percent)
Here is my desired output, where factors are ordered in bar and line chart:
And here is the undesired plot, where factor changes order in the line chart:
EDIT: adding theme_solarized_2(light = F) + scale_fill_solarized('blue') + scale_color_solarized('blue')
made the factor ordering consistent. Thanks!