2
I need to adjust the position of a text in the bar graph 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))
I added
geom_text(aes(label = n, y = n+1), size = 3.0, position = position_dodge(width = 0.2))
And nothing happened– Flavio Silva
tries to add a higher value because of the axis scale
y
– Rafael Cunha
I managed to solve the
geom_text(aes(label = n, y = n+3000), size = 3.0, position = position_dodge(width = 0.2))
to solve the problem.– Flavio Silva