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
XandYshould be one greater than those ofC; if the dimensions are the same, then the last row and column ofCwill 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
XandYare 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
vminandvmaxare used in conjunction withnormto normalize luminance data. If either isNone, it is autoscaled to the respective min or max of the color arrayC. If notNone,vminorvmaxpassed in here override any pre-existing values supplied in thenorminstance.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.CollectionOther Parameters: antialiaseds : bool, optional, default: False
The default
antialiasedsis False if the defaultedgecolors="none"is used. This eliminates artificial lines at patch boundaries, and works regardless of the value of alpha. Ifedgecolorsis not “none”, then the defaultantialiasedsis taken fromrcParams['patch.antialiased'], which defaults to True. Stroking the edges may be preferred ifalphais 1, but will cause artifacts otherwise.**kwargs :
Any unused keyword arguments are passed along to the
PolyCollectionconstructor:Property Description agg_filterunknown alphafloat or None animated[True | False] antialiasedor antialiasedsBoolean or sequence of booleans arrayunknown clima length 2 sequence of floats clip_boxa matplotlib.transforms.Bboxinstanceclip_on[True | False] clip_path[ ( Path,Transform) |Patch| None ]cmapa colormap or registered colormap name colormatplotlib color arg or sequence of rgba tuples containsa callable function edgecoloror edgecolorsmatplotlib color spec or sequence of specs facecoloror facecolorsmatplotlib color spec or sequence of specs figurea matplotlib.figure.Figureinstancegidan id string hatch[ ‘/’ | ‘' | ‘|’ | ‘-‘ | ‘+’ | ‘x’ | ‘o’ | ‘O’ | ‘.’ | ‘*’ ] labelstring or anything printable with ‘%s’ conversion. linestyleor dashes or linestyles[‘solid’ | ‘dashed’, ‘dashdot’, ‘dotted’ | (offset, on-off-dash-seq) | '-'|'--'|'-.'|':'|'None'|' '|'']linewidthor linewidths or lwfloat or sequence of floats normunknown offset_positionunknown offsetsfloat or sequence of floats path_effectsunknown picker[None|float|boolean|callable] pickradiusunknown rasterized[True | False | None] sketch_paramsunknown snapunknown transformTransforminstanceurla url string urlsunknown visible[True | False] zorderany number See also
pcolormesh- for an explanation of the differences between pcolor and pcolormesh.
Notes
X,YandCmay be masked arrays. If either C[i, j], or one of the vertices surrounding C[i,j] (XorYat [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
Cwith shape (nrows, ncolumns) is plotted with the column number asXand the row number asY, increasing up; hence it is plotted the way the array would be printed, except that theYaxis is reversed. That is,Cis 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 ifXandYare not specified, or ifXandYhave 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