matplotlib.pyplot.pcolormesh(*args, alpha=None, norm=None, cmap=None, vmin=None, vmax=None, shading='flat', antialiased=False, data=None, **kwargs)
[source]
Create a pseudocolor plot with a non-regular rectangular grid.
Call signature:
pcolor([X, Y,] C, **kwargs)
X and Y can be used to specify the corners of the quadrilaterals.
Note
pcolormesh()
is similar to pcolor()
. It's much faster and preferred in most cases. For a detailed discussion on the differences see Differences between pcolor() and pcolormesh().
Parameters: |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Returns: |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Other Parameters: |
|
See also
pcolor
imshow
imshow
can be a faster alternative.Masked arrays
C may be a masked array. If C[i, j]
is masked, the corresponding quadrilateral will be transparent. Masking of X and Y is not supported. Use pcolor
if you need this functionality.
Grid orientation
The grid orientation follows the standard matrix convention: An array C with shape (nrows, ncolumns) is plotted with the column number as X and the row number as Y.
Differences between pcolor() and pcolormesh()
Both methods are used to create a pseudocolor plot of a 2-D array using quadrilaterals.
The main difference lies in the created object and internal data handling: While pcolor
returns a PolyCollection
, pcolormesh
returns a QuadMesh
. The latter is more specialized for the given purpose and thus is faster. It should almost always be preferred.
There is also a slight difference in the handling of masked arrays. Both pcolor
and pcolormesh
support masked arrays for C. However, only pcolor
supports masked arrays for X and Y. The reason lies in the internal handling of the masked values. pcolor
leaves out the respective polygons from the PolyCollection. pcolormesh
sets the facecolor of the masked elements to transparent. You can see the difference when using edgecolors. While all edges are drawn irrespective of masking in a QuadMesh, the edge between two adjacent masked quadrilaterals in pcolor
is not drawn as the corresponding polygons do not exist in the PolyCollection.
Another difference is the support of Gouraud shading in pcolormesh
, which is not available with pcolor
.
Note
In addition to the above described arguments, this function can take a data keyword argument. If such a data argument is given, the following arguments are replaced by data[<arg>]:
Objects passed as data must support item access (data[<arg>]
) and membership test (<arg> in data
).
matplotlib.pyplot.pcolormesh
© 2012–2018 Matplotlib Development Team. All rights reserved.
Licensed under the Matplotlib License Agreement.
https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.pyplot.pcolormesh.html