I'm making a rather complicated bar chart, where I've added an additional pareto line. Usually my bar chart works fine - also with the geom_text() labels on top of the stacked bars. But now I can't seem to make it work. The geom_text() for the geom_bar() goes in the wrong order (top to buttom) on every bar, and I have no idea why. This is (some of) my code:
ggplot() +
theme_mso() +
geom_bar(data = uth.sum, aes(x = reorder(dpsd_ny, -n), y = n, fill = alvor), stat = "identity") +
geom_text(data = uth.sum, aes(x = reorder(dpsd_ny, -n), y = n, label = n), position = position_stack(vjust = .5)) +
scale_fill_manual(values = col) +
geom_point(data = uth.sum2, aes(x = dpsd_ny, y = akkumuleret)) +
geom_line(data = uth.sum2, aes(x = dpsd_ny, y = akkumuleret, group = 1), stat = "identity") +
scale_y_continuous(sec.axis = sec_axis(~(./total_value)*100, name = "Procent")) +
geom_text(data = uth.sum2, aes(x = dpsd_ny, y = akkumuleret, label = procent), position = position_stack(vjust= 1.08)) +
.... and so on. Hope it makes sense and that somebody can help!