tags:

views:

46

answers:

2

I have a 2D scatter plot in MATLAB. Is it possible to interpolate the scatter plot to create an area plot?

A: 

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).

Alex Feinman
+2  A: 

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:

alt text

gnovice
You win the 'psychic award' for this one. ;)
Alex Feinman

related questions