ggplot:如何绘制二维散点图的轮廓线以概述数据点 [英] ggplot: How to draw contour line for 2d scatter plot to outline the data points
本文介绍了ggplot:如何绘制二维散点图的轮廓线以概述数据点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要在x-y空间内绘制的所有数据点周围画一条线.我不需要二维密度分布.参见所附图片(该字段是手动绘制的).谢谢你.在数据点周围有线的散点图
I need to draw a line around all of my data points that plot within x-y space. I do not need 2d density distribution. See the picture attached (the field was just drawn manually). Thank you. 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()
这篇关于ggplot:如何绘制二维散点图的轮廓线以概述数据点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文