ggplot:如何画轮廓线的二维散点图勾勒出的数据点(ggplot: How to draw con

2019-09-28 03:17发布

我要画一条线周围所有的数据点的XY空间内的情节。 我不需要2D密度分布。 见附图画面(场刚刚手工画出)。 谢谢。 散点图周围的数据点线

Answer 1:

这是一个完美的使用情况ggaltgeom_encircle

#install.packages('ggalt')
library(ggalt)
#> Loading required package: ggplot2

ggplot(iris, aes(Sepal.Length, Sepal.Width)) +
  geom_point() +
  geom_encircle()

您还可以通过组包围:

ggplot(iris, aes(Sepal.Length, Sepal.Width, color = Species)) +
  geom_point() +
  geom_encircle()



文章来源: ggplot: How to draw contour line for 2d scatter plot to outline the data points