ggplot:如何绘制二维散点图的轮廓线以勾勒数据点
ggplot: How to draw contour line for 2d scatter plot to outline the data points
我需要在 x-y space 内绘制的所有数据点周围画一条线。我不需要二维密度分布。请参阅所附图片(该字段只是手动绘制的)。谢谢你。
scatter plot with line around data points
这是 ggalt
的 geom_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()
我需要在 x-y space 内绘制的所有数据点周围画一条线。我不需要二维密度分布。请参阅所附图片(该字段只是手动绘制的)。谢谢你。 scatter plot with line around data points
这是 ggalt
的 geom_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()