有没有办法添加自定义图例。现在,图例显示的是"a“列,我们可以显示"legend”列吗?因为"legend“列既有标签又有值。我们可以这样做吗?:)
library('ggplot2')
asd <- data.frame(a = c("fds","fdsf"), b = c(3,4))
asd$legend <- paste0(asd$a,"-",asd$b)
ggplot(asd, aes(x="", y=b, fill = a)) + geom_bar(stat = "identity", width = 1) + coord_polar(theta = "y")发布于 2020-09-18 18:11:57
可以,只需将填充映射到legend列:
ggplot(asd, aes(x = "", y = b, fill = legend)) +
geom_bar(stat = "identity", width = 1) +
coord_polar(theta = "y")

https://stackoverflow.com/questions/63953586
复制相似问题