[Matplotlib-users] Pcolormesh vs contourf

Eric Firing efiring at hawaii.edu
Thu Jan 5 20:20:15 EST 2017


Sameer,

They are fundamentally different in what they do; this is most clear if 
you experiment with using both methods on a low-resolution field (say 10 
by 12 points), and with a small number of contours (5 or 10). 
Contouring is most typically done with a moderate number of contours, 
maybe 30 or fewer.  It is most immediately appropriate for data values 
at discrete points, since it is interpolating.  pcolormesh does not 
interpolate, but shows the value in each quadrilateral as a block of 
solid color, so it is more like an image.

There are data sets and situations for which either of the two methods 
can be appropriate, and other cases where one is clearly better than the 
other.  For a somewhat noisy field, pcolormesh is usually better; it 
allows one to see the signal and the noise, and let one's eye pick out 
the former.  Isolated extreme values are represented better with 
pcolormesh.  For smoother fields and for seeing large-scale structure, 
contourf may be more appropriate.

What kind of data are you plotting?

Eric


On 2017/01/05 2:40 PM, Sameer Grover wrote:
> Hello,
>
> I'd like to know about the difference between contourf and pcolormesh
> and their intended uses. So far, I've been using contourf with a large
> number of levels (150 - 200) to plot two dimensional data. Are their any
> disadvantages of this and is pcolormesh better suited for this task?
>
> As far as I can make out, contourf displays a "smoothened-out" image and
> pcolormesh is more "boxy".
>
> Thanks.
>
> Sameer
>
>
>
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users at python.org
> https://mail.python.org/mailman/listinfo/matplotlib-users
>



More information about the Matplotlib-users mailing list