I created a ggplot2 bar plot and added a label, with the bar y-value, above the bar.
d <- data.frame(
Ano=2000+5*0:10,
Populacao =c(6.1,6.5,6.9,7.3,7.7,8.0,8.3,8.6,8.9,9.1,9.3)
)
d %>% ggplot(aes(x=Ano, y=Populacao)) + geom_bar(stat="identity") +
geom_text(aes(label=Populacao), vjust=-0.5)
Notice how the label on the highest column gets cut.
Is there a way for the plot to automatically adjust to the presence of the label?
EDIT: I know I can adjust this manually with scale_y_continuous(breaks=seq(0, 10, 1), limits=c(0,10))
expand_limits(y = max(d$Populacao * 1.05))
. – Naturalism