Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Matlab Matlab -- how to make a smooth contour plot?

  1. Jun 28, 2017 #1


    User Avatar
    Gold Member

    I want to represent data with 2 variables in 2D format. The value is represented by color and the 2 variables as the 2 axis. I am using the contourf function to plot my data:


    set(h, 'edgecolor','none');
    Both xrow and ycol are 6x6 matrices representing the coordinates. BDmatrix is the 6x6 matrix representing the corresponding data. However, what I got the picture as attached.

    Would it be possible for the contour color to vary smoothly rather than appearing as straight lines joining the data points? The problem of this figure is the coarse-granularity which is not appealing. I have tried to replace contourf with imagec but it seems not working. I am using MATLAB R2015b.

    Attached Files:

    • BD.jpg
      File size:
      31.3 KB
  2. jcsd
  3. Jun 29, 2017 #2


    User Avatar
    Science Advisor
    Gold Member

    You are seeing the effects of plotting on just a 6x6 grid. The contours would look smooth if your data were on, say, a 200x200 grid. I don't know what to do except to generate denser data or maybe look for software that uses different contour generation methods.
  4. Jun 29, 2017 #3


    User Avatar
    Science Advisor
    Gold Member
    2017 Award

  5. Jul 16, 2017 #4
    Try using interp2() or griddedInterpolant() to make more data point locations before passing the image to contourf().
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted

Similar Threads - Matlab smooth contour Date
How to program this in Matlab Feb 28, 2018
Matlab Making a short test for self-adjointness Feb 23, 2018
Matlab Plotting Coordinate Transformations in Matlab Feb 12, 2018
Matlab imshow Pixel smoothing Apr 22, 2016