On this page
matplotlib.axes.Axes.pcolor
Axes.pcolor(*args, data=None, **kwargs)
-
Create a pseudocolor plot of a 2-D array.
Call signatures:
pcolor(C, **kwargs) pcolor(X, Y, C, **kwargs)
pcolor can be very slow for large arrays; consider using the similar but much faster
pcolormesh()
instead.Parameters: C : array_like
An array of color values.
X, Y : array_like, optional
If given, specify the (x, y) coordinates of the colored quadrilaterals; the quadrilateral for
C[i,j]
has corners at:(X[i, j], Y[i, j]), (X[i, j+1], Y[i, j+1]), (X[i+1, j], Y[i+1, j]), (X[i+1, j+1], Y[i+1, j+1])
Ideally the dimensions of
X
andY
should be one greater than those ofC
; if the dimensions are the same, then the last row and column ofC
will be ignored.Note that the column index corresponds to the x-coordinate, and the row index corresponds to y; for details, see the Grid Orientation section below.
If either or both of
X
andY
are 1-D arrays or column vectors, they will be expanded as needed into the appropriate 2-D arrays, making a rectangular grid.cmap :
Colormap
, optional, default: NoneIf
None
, default to rc settings.norm :
matplotlib.colors.Normalize
, optional, default: NoneAn instance is used to scale luminance data to (0, 1). If
None
, defaults tonormalize()
.vmin, vmax : scalar, optional, default: None
vmin
andvmax
are used in conjunction withnorm
to normalize luminance data. If either isNone
, it is autoscaled to the respective min or max of the color arrayC
. If notNone
,vmin
orvmax
passed in here override any pre-existing values supplied in thenorm
instance.edgecolors : {None, ‘none’, color, color sequence}
If None, the rc setting is used by default. If ‘none’, edges will not be visible. An mpl color or sequence of colors will set the edge color.
alpha : scalar, optional, default: None
The alpha blending value, between 0 (transparent) and 1 (opaque).
snap : bool, optional, default: False
Whether to snap the mesh to pixel boundaries.
Returns: collection :
matplotlib.collections.Collection
Other Parameters: antialiaseds : bool, optional, default: False
The default
antialiaseds
is False if the defaultedgecolors="none"
is used. This eliminates artificial lines at patch boundaries, and works regardless of the value of alpha. Ifedgecolors
is not “none”, then the defaultantialiaseds
is taken fromrcParams['patch.antialiased']
, which defaults to True. Stroking the edges may be preferred ifalpha
is 1, but will cause artifacts otherwise.**kwargs :
Any unused keyword arguments are passed along to the
PolyCollection
constructor:Property Description agg_filter
unknown alpha
float or None animated
[True | False] antialiased
or antialiasedsBoolean or sequence of booleans array
unknown clim
a length 2 sequence of floats clip_box
a matplotlib.transforms.Bbox
instanceclip_on
[True | False] clip_path
[ ( Path
,Transform
) |Patch
| None ]cmap
a colormap or registered colormap name color
matplotlib color arg or sequence of rgba tuples contains
a callable function edgecolor
or edgecolorsmatplotlib color spec or sequence of specs facecolor
or facecolorsmatplotlib color spec or sequence of specs figure
a matplotlib.figure.Figure
instancegid
an id string hatch
[ ‘/’ | ‘' | ‘|’ | ‘-‘ | ‘+’ | ‘x’ | ‘o’ | ‘O’ | ‘.’ | ‘*’ ] label
string or anything printable with ‘%s’ conversion. linestyle
or dashes or linestyles[‘solid’ | ‘dashed’, ‘dashdot’, ‘dotted’ | (offset, on-off-dash-seq) | '-'
|'--'
|'-.'
|':'
|'None'
|' '
|''
]linewidth
or linewidths or lwfloat or sequence of floats norm
unknown offset_position
unknown offsets
float or sequence of floats path_effects
unknown picker
[None|float|boolean|callable] pickradius
unknown rasterized
[True | False | None] sketch_params
unknown snap
unknown transform
Transform
instanceurl
a url string urls
unknown visible
[True | False] zorder
any number See also
pcolormesh
- for an explanation of the differences between pcolor and pcolormesh.
Notes
X
,Y
andC
may be masked arrays. If either C[i, j], or one of the vertices surrounding C[i,j] (X
orY
at [i, j], [i+1, j], [i, j+1], [i+1, j+1]) is masked, nothing is plotted.The grid orientation follows the MATLAB convention: an array
C
with shape (nrows, ncolumns) is plotted with the column number asX
and the row number asY
, increasing up; hence it is plotted the way the array would be printed, except that theY
axis is reversed. That is,C
is taken asC
(y, x).Similarly for
meshgrid()
:x = np.arange(5) y = np.arange(3) X, Y = np.meshgrid(x, y)
is equivalent to:
X = array([[0, 1, 2, 3, 4], [0, 1, 2, 3, 4], [0, 1, 2, 3, 4]]) Y = array([[0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [2, 2, 2, 2, 2]])
so if you have:
C = rand(len(x), len(y))
then you need to transpose C:
pcolor(X, Y, C.T)
or:
pcolor(C.T)
MATLAB
pcolor()
always discards the last row and column ofC
, but Matplotlib displays the last row and column ifX
andY
are not specified, or ifX
andY
have one more row and column thanC
.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>]:
- All positional and all keyword arguments.
© 2012–2017 Matplotlib Development Team. All rights reserved.
Licensed under the Matplotlib License Agreement.
http://matplotlib.org/2.1.0/api/_as_gen/matplotlib.axes.Axes.pcolor.html