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

    kelvin490

    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:

    load('data.mat')
    cMap=jet(256);
    F2=figure(1);

    [c,h]=contourf(xrow,ycol,BDmatrix);
    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
      BD.jpg
      File size:
      31.3 KB
      Views:
      42
  2. jcsd
  3. Jun 29, 2017 #2

    marcusl

    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

    FactChecker

    User Avatar
    Science Advisor
    Gold Member

  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 Discussions: Matlab -- how to make a smooth contour plot?
  1. Matlab contour plot (Replies: 2)

  2. MATLAB - Contour plot (Replies: 1)

Loading...