开发者

turn scatter plot into area plot

I have a 2D scatter plot in MATLAB. Is it开发者_开发知识库 possible to interpolate the scatter plot to create an area plot?


If you're simply trying to draw one large filled polygon around your entire set of scattered points, you can use the function CONVHULL to find the convex hull containing your points and the function PATCH to display the convex hull:

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)

And here's the resulting figure:

turn scatter plot into area plot


Scatter is generally used to represent data where you can't use a line graph, i.e., where each x might have many different y values, so you can't convert directly to an area graph--it would be meaningless. If your data actually is representable as a line graph, then pass it to area directly.

So I'm not quite sure what you want, but here are some possibilities:

  1. You could create a Voronoi diagram based on your points. This will show a region near your points showing which points are closer to a specific point: voronoi(x,y), or see the help.

  2. You could bucket or quantize your data somehow, making it fit into a grid, and then plot the grid. This could also be considered a histogram, so read up on that.

  3. You could just use larger scatter markers (scatter(x,y,scale) where scale is the same dimensions as x and y).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜