I created a proportion barplot:
df <- data.frame(speech = c("figurative", "literal", "figurative", "literal"),
meaning = c("kill", "seek", "seek", "kill"),
amount = c(47, 2260, 588, 5639))
ggplot(df, aes(x=speech,y=amount, fill=meaning, group = meaning)) geom_bar(stat = "identity", position="fill")
How can I add labels showing the amount (not the proportion)?
CodePudding user response:
Is this what you mean? Adding labels based on the values for amount.
df <- data.frame(speech = c("figurative", "literal", "figurative", "literal"),
meaning = c("kill", "seek", "seek", "kill"),
amount = c(47, 2260, 588, 5639))
ggplot(df, aes(x=speech,y=amount, fill=meaning, group = meaning))
geom_bar(stat = "identity", position="fill")
geom_text(aes(label = amount), position = position_fill(vjust = 0.5))