我創建了一個比例條形圖:
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")
如何添加顯示數量(而不是比例)的標簽?
uj5u.com熱心網友回復:
你是這個意思嗎?根據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))
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/315850.html