matplotlib.axes.Axes.pcolor¶

Axes.
pcolor
(self, *args, shading=None, alpha=None, norm=None, cmap=None, vmin=None, vmax=None, data=None, **kwargs)[source]¶ Create a pseudocolor plot with a nonregular rectangular grid.
Call signature:
pcolor([X, Y,] C, **kwargs)
X and Y can be used to specify the corners of the quadrilaterals.
Hint
pcolor()
can be very slow for large arrays. In most cases you should use the similar but much fasterpcolormesh
instead. See Differences between pcolor() and pcolormesh() for a discussion of the differences.Parameters:  C2D arraylike
The colormapped values.
 X, Yarraylike, optional
The coordinates of the corners of quadrilaterals of a pcolormesh:
(X[i+1, j], Y[i+1, j]) (X[i+1, j+1], Y[i+1, j+1]) ++   ++ (X[i, j], Y[i, j]) (X[i, j+1], Y[i, j+1])
Note that the column index corresponds to the xcoordinate, and the row index corresponds to y. For details, see the Notes section below.
If
shading='flat'
the dimensions of X and Y should be one greater than those of C, and the quadrilateral is colored due to the value atC[i, j]
. If X, Y and C have equal dimensions, a warning will be raised and the last row and column of C will be ignored.If
shading='nearest'
, the dimensions of X and Y should be the same as those of C (if not, a ValueError will be raised). The colorC[i, j]
will be centered on(X[i, j], Y[i, j])
.If X and/or Y are 1D arrays or column vectors they will be expanded as needed into the appropriate 2D arrays, making a rectangular grid.
 shading{'flat', 'nearest', 'auto'}, optional
The fill style for the quadrilateral; defaults to 'flat' or
rcParams["pcolor.shading"]
(default:'flat'
). Possible values: 'flat': A solid color is used for each quad. The color of the
quad (i, j), (i+1, j), (i, j+1), (i+1, j+1) is given by
C[i, j]
. The dimensions of X and Y should be one greater than those of C; if they are the same as C, then a deprecation warning is raised, and the last row and column of C are dropped.  'nearest': Each grid point will have a color centered on it, extending halfway between the adjacent grid centers. The dimensions of X and Y must be the same as C.
 'auto': Choose 'flat' if dimensions of X and Y are one larger than C. Choose 'nearest' if dimensions are the same.
See pcolormesh grids and shading for more description.
 'flat': A solid color is used for each quad. The color of the
quad (i, j), (i+1, j), (i, j+1), (i+1, j+1) is given by
 cmapstr or
Colormap
, default:rcParams["image.cmap"]
(default:'viridis'
) A Colormap instance or registered colormap name. The colormap maps the C values to colors.
 norm
Normalize
, optional The Normalize instance scales the data values to the canonical colormap range [0, 1] for mapping to colors. By default, the data range is mapped to the colorbar range using linear scaling.
 vmin, vmaxfloat, default: None
The colorbar range. If None, suitable min/max values are automatically chosen by the
Normalize
instance (defaults to the respective min/max values of C in case of the default linear scaling). It is deprecated to use vmin/vmax when norm is given. edgecolors{'none', None, 'face', color, color sequence}, optional
The color of the edges. Defaults to 'none'. Possible values:
 'none' or '': No edge.
 None:
rcParams["patch.edgecolor"]
(default:'black'
) will be used. Note that currentlyrcParams["patch.force_edgecolor"]
(default:False
) has to be True for this to work.  'face': Use the adjacent face color.
 A color or sequence of colors will set the edge color.
The singular form edgecolor works as an alias.
 alphafloat, default: None
The alpha blending value of the face color, between 0 (transparent) and 1 (opaque). Note: The edgecolor is currently not affected by this.
 snapbool, default: False
Whether to snap the mesh to pixel boundaries.
Returns: Other Parameters:  antialiasedsbool, default: False
The default antialiaseds is False if the default edgecolors="none" is used. This eliminates artificial lines at patch boundaries, and works regardless of the value of alpha. If edgecolors is not "none", then the default antialiaseds is taken from
rcParams["patch.antialiased"]
(default:True
). Stroking the edges may be preferred if alpha is 1, but will cause artifacts otherwise. **kwargs
Additionally, the following arguments are allowed. They are passed along to the
PolyCollection
constructor:Property Description agg_filter
a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array alpha
arraylike or scalar or None animated
bool antialiased
or aa or antialiasedsbool or list of bools array
ndarray or None capstyle
CapStyle
or {'butt', 'projecting', 'round'}clim
(vmin: float, vmax: float) clip_box
Bbox
clip_on
bool clip_path
Patch or (Path, Transform) or None cmap
Colormap
or str or Nonecolor
color or list of rgba tuples contains
unknown edgecolor
or ec or edgecolorscolor or list of colors or 'face' facecolor
or facecolors or fccolor or list of colors figure
Figure
gid
str hatch
{'/', '\', '', '', '+', 'x', 'o', 'O', '.', '*'} in_layout
bool joinstyle
JoinStyle
or {'miter', 'round', 'bevel'}label
object linestyle
or dashes or linestyles or lsstr or tuple or list thereof linewidth
or linewidths or lwfloat or list of floats norm
Normalize
or Noneoffset_position
unknown offsets
(N, 2) or (2,) arraylike path_effects
AbstractPathEffect
picker
None or bool or float or callable pickradius
float rasterized
bool sketch_params
(scale: float, length: float, randomness: float) snap
bool or None transform
Transform
url
str urls
list of str or None visible
bool zorder
float
See also
pcolormesh
 for an explanation of the differences between pcolor and pcolormesh.
imshow
 If X and Y are each equidistant,
imshow
can be a faster alternative.
Notes
Masked arrays
X, Y and C may be masked arrays. If either
C[i, j]
, or one of the vertices surroundingC[i, j]
(X or Y at[i, j], [i+1, j], [i, j+1], [i+1, j+1]
) is masked, nothing is plotted.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.
Note
In addition to the above described arguments, this function can take a data keyword argument. If such a data argument is given, every other argument can also be string
s
, which is interpreted asdata[s]
(unless this raises an exception).Objects passed as data must support item access (
data[s]
) and membership test (s in data
).