-1
我只是想設置點的顏色和大小。 我發現不少帖子,但沒有任何我能夠逆向工程。 這可能嗎?使用密度來設置顏色和點的大小使用ggplot
require(ggplot2)
d <- ggplot(diamonds, aes(price)) #+ xlim(0, 3)
d + stat_bin(aes(size = ..density.., color=..density..),
binwidth = 0.1,geom = "point",
position="jitter") +
guides(col = guide_legend(override.aes = list(shape = 15, size = 10)))
編輯:我想我知道了,但現在我的問題變成了我做的是正確的還是黑客?新代碼:
require(ggplot2)
d <- ggplot(diamonds, aes(price)) #+ xlim(0, 3)
d + stat_bin(aes(size = ..density.., color=..density..),
binwidth = 0.1,geom = "point",
position="jitter") +
guides(col = guide_legend(override.aes = list(shape = c(16,16,16,16,16),
size = c(2,3,4,5,6))))