0

i'm trying to plot an outline of a scatter plot I have. I don't want any of the markers of the scatter only a line that outline the cloud of points and if at all possible to fill it with color. thanks!

    x = linspace(0,3*pi,200);
    y = cos(x) + rand(1,200);
    scatter(x,y)
Dan
  • 45,079
  • 17
  • 88
  • 157

2 Answers2

1

It sounds like you want to plot a convex hull for which you can use the MATLAB convhull function.

Dan
  • 45,079
  • 17
  • 88
  • 157
1

Dan's answer is probably the best way to go. Since it isn't clear whether you need a minimum hull or a spline-fit to the extreme points, I'll just suggest the latter as an option. Roughly speaking, decide what a reasonable minimum radius should be, then scan from 0 to 2*pi , collecting the points of max radius (so long as that's greater than your selected minumum) at each sampled angle. The fit a spline to that set of points.

This sort of problem can get extremely complicated, as in this paper, BTW.

Edit: to answer Dan's question: Matlab's got nothing builtin that I know of; I would choose the center to be one of the centroids: The mean x, y values of all points is a standard method. If you have a theory as to the underlying distribution, e.g., 2D gaussian, you could try fitting the data to a distribution function and interpolating the centroid thereof.

Carl Witthoft
  • 20,573
  • 9
  • 43
  • 73
  • That's an interesting method, does MATLAB have something like this pre-built? Also, how do you choose the center? – Dan Mar 10 '16 at 12:46