matplotlib.pyplot.pcolor(*args, alpha=None, norm=None, cmap=None, vmin=None, vmax=None, 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.


pcolor() can be very slow for large arrays. In most cases you should use the similar but much faster pcolormesh instead. See there for a discussion of the differences.


A scalar 2-D array. The values will be color-mapped.

X, Yarray-like, optional

The coordinates of the quadrilateral corners. The quadrilateral for C[i, j] has corners at:

(X[i+1, j], Y[i+1, j])           (X[i+1, j+1], Y[i+1, j+1])
                      | C[i, j] |
    (X[i, j], Y[i, j])           (X[i, j+1], Y[i, j+1])

Note that the column index corresponds to the x-coordinate, and the row index corresponds to y. For details, see the Notes section below.

The dimensions of X and Y should be one greater than those of C. Alternatively, X, Y and C may have equal dimensions, in which case the last row and column of C will be ignored.

If X and/or Y are 1-D arrays or column vectors they will be expanded as needed into the appropriate 2-D arrays, making a rectangular grid.

cmapstr or Colormap, optional

A Colormap instance or registered colormap name. The colormap maps the C values to colors. Defaults to rcParams["image.cmap"] (default: 'viridis').

normNormalize, 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, vmaxscalar, optional, 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).

edgecolors{'none', None, 'face', color, color sequence}, optional

The color of the edges. Defaults to 'none'. Possible values:

The singular form edgecolor works as an alias.

alphascalar, optional, 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, optional, default: False

Whether to snap the mesh to pixel boundaries.

Other Parameters:
antialiasedsbool, optional, 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.


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 float or None
animated bool
antialiased or aa or antialiaseds bool or sequence of bools
array ndarray
capstyle {'butt', 'round', 'projecting'}
clim (vmin: float, vmax: float)
clip_box Bbox
clip_on bool
clip_path Patch or (Path, Transform) or None
cmap colormap or registered colormap name
color color or sequence of rgba tuples
contains callable
edgecolor or ec or edgecolors color or sequence of colors or 'face'
facecolor or facecolors or fc color or sequence of colors
figure Figure
gid str
hatch {'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
in_layout bool
joinstyle {'miter', 'round', 'bevel'}
label object
linestyle or dashes or linestyles or ls {'-', '--', '-.', ':', '', (offset, on-off-seq), ...}
linewidth or linewidths or lw float or sequence of floats
norm Normalize
offset_position {'screen', 'data'}
offsets array-like (N, 2) or (2,)
path_effects AbstractPathEffect
picker None or bool or float or callable
pickradius unknown
rasterized bool or None
sketch_params (scale: float, length: float, randomness: float)
snap bool or None
transform Transform
url str
urls List[str] or None
visible bool
zorder float

See also

for an explanation of the differences between pcolor and pcolormesh.
If X and Y are each equidistant, imshow can be a faster alternative.


Masked arrays

X, Y and C may be masked arrays. If either C[i, j], or one of the vertices surrounding C[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.

Handling of pcolor() end-cases

pcolor() displays all columns of C if X and Y are not specified, or if X and Y have one more column than C. If X and Y have the same number of columns as C then the last column of C is dropped. Similarly for the rows.

Note: This behavior is different from MATLAB's pcolor(), which always discards the last row and column of C.


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>]:

  • All positional and all keyword arguments.

Objects passed as data must support item access (data[<arg>]) and membership test (<arg> in data).