Problem with the width of a single bar in a barchart

Viewed 44

I do not know how to formulate my question, so here is the problem:

my code:

  geom_bar(position = "dodge", stat="count")+
  scale_fill_grey(labels = c("Besetzt", "Unbesetzt"))+
  labs(y="Anzahl an Kästen",
       x="Objekt",
       caption="Fig. 1: Vergleich des Besatzes der Objekte an denen die Kästen angebracht sind")+
  theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),
        panel.background = element_blank(), axis.line = element_line(colour = "black"))

and here is my plot: It shows the numbers of occupied (grey) and unoccupied (black) bat boxes dependent on the object the bat box is mounted on

My problem is the first bar Balkon. It is double the width of the others, because no bat box mounted on a Balkon is occupied. How can I change it, that the black part of the bar Balkon has the same width as the others.

I am very thankfull for ervery help I can get.

1 Answers

You need to change the follwing line:

...geom_bar(position = "dodge", stat="count")

To:

...geom_bar(position = position_dodge(preserve = 'single'), stat="count")

This will unify the size of the bars

Related