I'm trying to find a way to increase the spacing between the text labels in my stacked barcharts so that they don't overlap. No amount of vertical adjustment will space them further.
geom_text(size = 6, position = position_stack(), vjust = -0.5) :

Here is an example using geom_text_repel() from the ggrepel package.
library(ggplot2)
library(ggrepel)
library(reshape2)
DF <- read.table(text="Rank F1 F2
1 300 150 50
2 400 10 10
", header=TRUE)
DF1 <- melt(DF, id.var="Rank")
ggplot(DF1, aes(x = Rank, y = value, fill = variable)) +
geom_bar(stat = "identity")+
geom_text_repel(aes(label = variable),
nudge_y=0.5,
nudge_x=0)

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With