I have created a stacked histogram in ggplot. I would like to change the order of the stacked bars.
My dataset looks like this:
head(df)
difficulty RegularPool SuperPool Item_Pool
1 -3.1185 1 NA Regular
2 -2.9385 1 NA Regular
3 -2.8100 1 NA Regular
4 -2.2797 1 NA Regular
5 -3.3321 1 NA Regular
6 -3.0996 1 NA Regular
I create the ggplot:
ggplot(data = df,
aes(x = difficulty, color = Item_Pool, fill = Item_Pool)) +
geom_histogram(alpha= 0.5, position = "stack", binwidth = 0.1) +
geom_vline(xintercept = logit.placement, linetype = "dashed", color = "blue") + #add placement lines
annotate("text", x = logit.placement, y = 0, angle = 45, label=c("One Below", "Early","Mid", "Late", "One Above"), colour = "blue") + #label placement lines
xlim(-8, 7) +
ylab("Number of Testlets") +
xlab("Testlet Difficulty") +
ggtitle(paste("Grade ", grade, " Overall Cut = ", item.pool.cut, sep = ""))
How can I get the blue ("Super") bars to be on top of the red ("Regular") bars?