0

enter image description here

In bar chart values are appearing incorrectly.How to correct it.

ggplot(data=df, aes(x=Demand_Supply,fill=time_slot),position = 'stack') +  
       geom_bar()  +  facet_wrap(~`Pickup.point`) + 
       geom_text(stat='count',aes(label=abs(..count..)))
Roman Luštrik
  • 69,533
  • 24
  • 154
  • 197
  • This is a duplicate- see here: https://stackoverflow.com/questions/39269895/labels-overlapping-on-stacked-bar-chart-ggplot2 – Connor Dibble Dec 14 '19 at 00:46

1 Answers1

0

You can control it using vjust and hjust.

Try following:

ggplot(data=df, aes(x=Demand_Supply,fill=time_slot),position = 'stack')+ geom_bar() + facet_wrap(~Pickup.point)+
geom_text(stat='count',aes(label=abs(..count..)), , vjust = -0.5)

you can try different permutation and combination with hjust and vjust.

Bhavesh Ghodasara
  • 1,981
  • 2
  • 15
  • 29