Clear Filters
Clear Filters

How can I make contour lines smoother?

33 views (last 30 days)
Sandy on 14 Jun 2013
Commented: Konstantin on 3 Apr 2017
How can I make contour lines smoother?

Answers (3)

Kelly Kearney
Kelly Kearney on 20 Jun 2013
The easiest way to do this is to interpolate your data to a higher resolution using an interpolation scheme that will result in smoother transitions between points, such as a spline.
[x,y,z] = peaks(10);
[xnew, ynew] = meshgrid(linspace(-3,3,100));
znew = interp2(x,y,z,xnew,ynew, 'spline');
hold on;
scatter(x(:), y(:), [], z(:), 'filled');
contour(x,y,z, -6:7);
hold on;
scatter(x(:), y(:), [], z(:), 'filled');
contour(xnew, ynew, znew, -6:7);
Be careful with this, though, since it might introduce some artifacts. Even though it may not be as visually pleasing, the low-res, less-smooth version is a more accurate depiction of the underlying data.

Andrew Reibold
Andrew Reibold on 14 Jun 2013
Is it something you can try "binning"?
  1 Comment
Sandy on 17 Jun 2013
Edited: Sandy on 17 Jun 2013
Well the data has already been binned (hist3()).

Sign in to comment.

Image Analyst
Image Analyst on 20 Jun 2013
Please post an image or screenshot. For example, one way could be to blur your image with conv2() or imfilter() before you call contour().


Find more on Contour Plots in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!