Adding data values to a stacked bar chart?

27 Views Asked by At

i am doing a data science module at Uni, and am relatively new at R. I am having trouble with adding data values to my stacked chart, and have no clue on how to fix it.

My current code is this:

bp <- ggplot(race_death) +
   geom_bar(aes(x = Race, fill = Died)) +
   ggthemes::theme_economist()+ 
   scale_fill_manual(values = my_palette)+
   geom_label(aes(x = Race, y = n ,label = n), size = 3, position = position_stack(vjust = 0.5, reverse = FALSE), Deaths) bp +
   coord_flip()

But the graph shows this:

enter image description here

The numbers are correct, but they are in the wrong places, e.g. 454 should be in the middle of the green bar, instead of in the orange. How do i go about fixing this?

0

There are 0 best solutions below