Hey together, I have a question regarded to ggplot. I have these graphs and I want to read all the percentages of course, but if I change the contionous_scale_y with expand(c(0,0)) to another value e.g., expand (c(0,0.1)) then I can see the percentages but then the bars are of course not directly on the y-axis anymore. My question would be - how can I see all the percentages of my graph (see problem in screenshot), but the bars should still be sticked on the y-axsis - this is my Current code:
ggplot(data, aes(x = HHincome)) +
geom_bar(aes(y = (..count..)/sum(..count..)), fill ="blue") +
geom_text(aes(y = ((..count..)/sum(..count..)), label = scales::percent(round(..count..)/sum(..count..),0.01)), stat = "count", hjust = -0.2, size = 3, family = "Times New Roman", colour = "black") +
scale_y_continuous(labels = percent, expand = c(0,0)) +
labs(title = "Distribution of Variable Household Income") +
coord_flip() +
theme(panel.background = element_blank(), text = element_text(family = "Times New Roman", size = 10),axis.ticks.x = element_blank(), axis.text.x = element_blank(), axis.title.x = element_blank(), plot.title = element_text(size = 12, hjust = 0.5, vjust = 3), axis.title.y = element_blank(), axis.line.y = element_line(size = 0.5, colour = "black"))
Help is highly appreciated! Thank you so much!