0

I am trying to run a graph counting the amount of people based on agegroup and sex. I will attach the code below and the graph. Not sure why the females in the 18-49 group are not showing up.

 # Count of people per age group per age
 sc <- (c("#c994c7", "#9ecae1"))
 ggplot(uniquePeople, aes(x = ageGroup, group = sex, fill = sex)) +

geom_bar(position="dodge", col="white") +
 scale_y_continuous(breaks = seq(0, 80, by = 5), limits =  c(0, 80)) +
 theme(panel.grid.major = element_blank(),
 panel.grid.minor = element_blank(),
panel.border = element_blank(),
panel.background = element_blank()) +
scale_color_manual(values = sc)+
scale_fill_manual(values = sc)
zephryl
  • 14,633
  • 3
  • 11
  • 30
  • 2
    It’s hard to say without a [reproducible example](https://stackoverflow.com/q/5963269/17303805) including the data you’re using. But one possibility is the value for that group is outside the limits set in `scale_y_continuous()`. Either adjust the limits, or use `coord_cartesian(ylim = c(0, 80))` instead. – zephryl Feb 15 '23 at 00:23
  • That worked! How can i get the y axis to surpass 100? or show the count of each bar? – user21215346 Feb 15 '23 at 00:29
  • you can adjust the limits directly, e.g.: scale_y_continuous(..., limits=c(0, 110)). As for showing the count, e.g. via geom_text: geom_text(aes(label = ..count..), stat = "count", position="fill") – Sointu Feb 15 '23 at 09:10

0 Answers0