Text position in graphic using ggplot2

2

I need to adjust the position of a text in the bar chart so that it is above the bar. Below the code used

base.total %>%
  group_by(SEXO, REGIME.JURIDICO.FINAL)%>%
  count() %>%
  ggplot(., aes(x=reorder(SEXO, -n), y=n, fill = REGIME.JURIDICO.FINAL)) +
  geom_bar(stat="identity", width = 0.2, position = "dodge") +
  labs(title = "Gráfico 11: Quantidade de Inativos Civis e Militares",
       subtitle = "Fonte: Base de Dados SIGRH", x = "Sexo", y="Quantidade") + 
  theme(axis.line.x = element_line(size = .5, colour = "black"),
        axis.line.y = element_line(size = .5, colour = "black"),
        axis.text.x = element_text(colour = "black", size = 7),
        axis.text.y = element_text(colour = "black", size = 7),
        panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(), 
        panel.background = element_blank(),
        legend.title = element_blank()) +  
  geom_text(aes(label = n), size = 3.0, position = position_dodge(width = 0.2))

    
asked by anonymous 04.08.2017 / 14:23

1 answer

3

I found a suggestion in Stack Overflow in English (in this topic ). Adapting to your example, it would look like this

geom_text(aes(label=n, y = n+0.01), size = 3.0, position = position_dodge(width = 0.2))
    
04.08.2017 / 14:36