0

ggplot(data=enroll2, aes(x=ACTUAL_ENRL, y=DEPT, fill=Term))+geom_col(position="dodge", width = 0.60)

this results in

result

I need the chart to resemble the following (charted with python): python chart - same data

Data looks like the following: data structure

Any Ideas or help would be appreciated.

JTAR
  • 11
  • 2
  • 1
    There are workarounds for this (https://stackoverflow.com/questions/21409850/generate-paired-stacked-bar-charts-in-ggplot-using-position-dodge-only-on-some), but I think ggplot2 is a little awkward with dodged aggregated bars. I'd suggest summing upstream, like `library(dplyr); enroll2 %>% count(DEPT, Term, wt = "ACTUAL_ENRL", name = "ACTUAL_ENRL") %>% ggplot(aes(x=ACTUAL_ENRL, y=DEPT, fill=Term))+geom_col(position="dodge", width = 0.60)` – Jon Spring Oct 05 '22 at 18:40
  • By default `geom_col` will not compute the sum for you. Instead try with `stat_summary`, i.e. try `ggplot(data=enroll2, aes(x=ACTUAL_ENRL, y=DEPT, fill=Term)) + stat_summary(geom = "col", fun = "sum", position = "dodge", width = .6)` – stefan Oct 05 '22 at 18:48
  • @stefan thanks, that did the trick, now I know :) – JTAR Oct 06 '22 at 22:21

0 Answers0