When I place the values of bars of a barplot with geom_text on top of the bars, the values are cutted and not fully visible. How can I increase the "height" of the plot area so that the values are fully shown?
library(dplyr)
library(ggplot2)
library(ggthemes)
df <- tibble(
Wer = c('Abt1', 'Abt2'),
Einnahmen = c(221319.85, 9835.18)
)
df %>%
ggplot(aes(x=Wer, y=Einnahmen, fill=Wer)) +
geom_col(fill=c('darkblue', 'darkred'), width=0.6) +
geom_text(aes(label=scales::comma(Einnahmen, big.mark = '.', decimal.mark = ',', prefix = '\u20AC ')), vjust=-0.1, color="black", size=4) +
ggtitle('Einnahmen') +
scale_y_continuous(expand = expansion(mult = c(0, 0.1), add = c(0, 0))) +
scale_y_continuous(labels = scales::label_dollar(prefix='€', suffix='k', scale=0.001, big.mark='.', decimal.mark=',')) +
theme_minimal() +
theme(plot.title = element_text(size = 16)) +
theme(plot.title = element_text(hjust = 0.5)) +
theme(axis.text = element_text(size = 12)) +
theme(axis.title.x = element_blank()) +
theme(axis.title.y = element_blank())
I played around with scale_y_continuous
and expand
, but there are no effects.
Edit: I found out that when I use scale_y_continuous
to set the number formats to include the Euro symbol and the k for thousands the expand does not work. Is there a workaround to use the bars values instead of the labels?