登录论坛

查看完整版本 : 将散点图变成面积图


poster
2019-12-10, 20:48
我在MATLAB中有一个2D散点图。是否可以对散点图进行插值以创建面积图?



回答:

如果您只是想在整个散布点周围绘制一个大的填充多边形,则可以使用函数CONVHULL (http://www.mathworks.com/help/techdoc/ref/convhull.html)查找包含点的凸包,并使用PATCH (http://www.mathworks.com/help/techdoc/ref/patch.html)显示凸包:

x = rand(1,20); %# 20 random x values y = rand(1,20); %# 20 random y values hullPoints = convhull(x,y); %# Find the points defining the convex hull patch(x(hullPoints),y(hullPoints),'r'); %# Plot the convex hull in red hold on; %# Add to the existing plot scatter(x,y); %# Plot your scattered points (for comparison) 这是结果图:

https://i.stack.imgur.com/W5Sri.png



更多&回答... (https://stackoverflow.com/questions/3965627)