我在ggplot2中使用geom_point将值显示为每个点的区域:
geom_point(aes(size = sqrt(z/pi))
但是,图例单位是变换后的值,是否可以让图例显示原始值以及各自的气泡大小?
编辑:抱歉,我应该提供更多信息,以
开头library(ggplot2)
data <- data.frame(x = sample(1:10), y = sample(1:10), z = sample(1:10), colour = c("red", "yellow", "green","pink","black","brown","grey","white","purple","beige"))
ggplot(data, aes(x = x, y = y)) + geom_point(aes(size = sqrt(z/pi)), pch = 21) + aes(fill = colour) + scale_fill_brewer(palette = "set1")
答案 0 :(得分:1)
尝试添加:
+scale_colour_manual(guide = guide_legend(override.aes=aes(size=values)))