1

I want to create a grouped bar chart with ggplot. Groups are gender and age groups.

Problem: In age group 1, there are only females and no males, so the bar for that age group covers both genders. I want to change the size of the bar, so that one can see there are zero males.

The code is the following:

ggplot(data=daten, aes(x=AG, y=stat(count), group=factor(GESCHLECHT), fill=factor(GESCHLECHT)))+
  geom_bar(position=position_dodge(width = 1))+
  scale_fill_manual(values = c("steelblue","darkred"), labels=c("Männlich", "Weiblich"))+
  labs(y="Anzahl", x="Altersgruppen", fill="Geschlecht:")+
  scale_x_continuous(breaks=seq(1,3, by=1), labels=c("25 - \< 51","51 - \<65", "\>65"))+
  geom_text(aes(label=stat(count)),stat="count", vjust=-0.5, position=position_dodge(width = 1))+
  theme(legend.position="bottom")

How can I change the size? Many thanks in advance :-)

I really don't know how to solve this problem (I'm really a newbie with r)

current bar chart

tdy
  • 36,675
  • 19
  • 86
  • 83
pauschig
  • 11
  • 1

0 Answers0