【发布时间】:2016-08-30 22:24:43
【问题描述】:
这是我能够使它工作的示例:
find_hull <- function(df) df[chull(df$Sepal.Length, df$Sepal.Width), ]
hulls <- ddply(iris, "Species", find_hull)
ggplot(iris, aes(x=Sepal.Length, y=Sepal.Width, shape=Species,
color=Species, size=Petal.Width)) +
geom_point() +
ggtitle("Sepal.Length vs. Sepal.Width - size Petal.Width") +
scale_shape_manual(values=c(15,16,17)) +
geom_polygon(data = hulls, alpha = 0.15, size=0.2) +
scale_size(guide = "none")
我现在想做的是根据 Petal.Width 为每个组(即 setosa、versicolor 和 virginica)指定渐变。也就是说,假设 setosa 组是读取正方形,其中每个点的大小取决于 Petal.Width。我希望这种红色根据花瓣的宽度而变化(从白色到红色)。如果弗吉尼亚是蓝色三角形,我希望这些三角形的颜色也随大小(花瓣宽度)而变化。
有什么想法可以简单地做这样的事情吗?
【问题讨论】: