I've created a barplot and I want to make some changes in the layout. I've tried a couple of things but I want to do the following:
The plot can be found here: enter image description here
The code I provided is:
beoordeling <- ggplot(data=etadam, aes(x = beoordeling)) +
geom_bar(aes(y = (..count..)/sum(..count..)), colour = "black", width = 0.6, fill = '#ffd308') +
geom_text(aes(y = ((..count..)/sum(..count..)), label = scales::percent((..count..)/sum(..count..))), stat = "count", vjust = -0,2) +
scale_y_continuous(labels = percent) +
scale_x_continuous(breaks = seq(0, 10, by = 1)) +
labs(x = NULL, y = 'percentage', title = 'Welk cijfer geven jullie de examentraining?', subtitle = 'N = 400 | Alle trainingen', caption = 'Leren voor de Toekomst©')
This should do what you want:
beoordeling <- ggplot(data=etadam, aes(x = beoordeling)) +
theme_minimal() +
geom_bar(aes(y = (..count..)/sum(..count..)), colour = "black", width = 0.6, fill = '#ffd308') +
geom_text(aes(y = ((..count..)/sum(..count..)), label = scales::percent((..count..)/sum(..count..))), stat = "count", vjust = -0,2, size = 2) +
scale_y_continuous(limits=c(0.5), expand = c(0,0),labels = percent) +
scale_x_continuous(breaks = seq(0, 10, by = 1)) +
labs(x = NULL, y = 'percentage', title = 'Welk cijfer geven jullie de examentraining?', subtitle = 'N = 400 | Alle trainingen', caption = 'Leren voor de Toekomst©')
add limits = c(0,0.5)
and if you wish expand = c(0,0)
inside scale_y_continuous()
.
Change size
in geom_text()
. I set it to 2 at the moment
Use theme_minimal()
, theme_classic()
or theme_light()
. See ggplot themes
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.