rgg图等值线密度

oewdyzsn  于 2022-12-20  发布在  其他
关注(0)|答案(1)|浏览(122)

正在ggplot上浏览虹膜示例,收到以下错误消息,想知道为什么调整alpha无法解决问题。

library (datasets)
# Scatterplot, colored by species, fit line, density

    ggplot(iris, 
      aes(Petal.Width, Petal.Length,
        color = Species)) +
      geom_point(size = 3) +
      geom_smooth(method = lm) +
      geom_density2d(alpha = .5) +

  theme(legend.position = "bottom")
geom_smooth()` using formula 'y ~ x'
Warning messages:
1: stat_contour(): Zero contours were generated 
2: In min(x) : no non-missing arguments to min; returning Inf
3: In max(x) : no non-missing arguments to max; returning -Inf
4: stat_contour(): Zero contours were generated 
5: In min(x) : no non-missing arguments to min; returning Inf
6: In max(x) : no non-missing arguments to max; returning -Inf
oxiaedzo

oxiaedzo1#

我无法让bin大小起作用,所以经过一番研究,我找到了contour_var选项。

geom_density2d(alpha=0.5, contour_var = "ndensity")

这就成功了,并得到了IRIS数据集的预期结果(根据我所遵循的训练:-)

相关问题