Add values in each stackerd bar whit extensive data

I think your issue is that your bars are actually loads of little bars stacked up. If you summarise your data ahead of the plot you get the result you're looking for:

library(tidyverse)

tibble(data) %>% 
  group_by(MES, ANO) %>% 
  summarise(CANTIDAD = sum(CANTIDAD)) %>% 
  ggplot(aes(
    x = MES,
    y = CANTIDAD,
    fill = ANO,
    label = CANTIDAD
  )) +
  geom_bar(stat = 'identity') +
  geom_text(
    position = position_stack(vjust = .5), 
    aes(
      x = MES,
      y = CANTIDAD,
      label = CANTIDAD,
    ))

1 Like