matplotlib.axes.Axes.pcolorfast#

Axes.pcolorfast(*args,alpha=None,norm=None,cmap=None,vmin=None,vmax=None,colorizer=None,data=None,**kwargs)[source]#

Create a pseudocolor plot with a non-regular rectangular grid.

Call signature:

ax.pcolorfast([X,Y],C,/,**kwargs)

The argumentsX,Y,C are positional-only.

This method is similar topcolor andpcolormesh.It's designed to provide the fastest pcolor-type plotting with theAgg backend. To achieve this, it uses different algorithms internallydepending on the complexity of the input grid (regular rectangular,non-regular rectangular or arbitrary quadrilateral).

Warning

This method is experimental. Compared topcolor orpcolormesh it has some limitations:

  • It supports only flat shading (no outlines)

  • It lacks support for log scaling of the axes.

  • It does not have a pyplot wrapper.

Parameters:
Carray-like

The image data. Supported array shapes are:

  • (M, N): an image with scalar data. Color-mapping is controlledbycmap,norm,vmin, andvmax.

  • (M, N, 3): an image with RGB values (0-1 float or 0-255 int).

  • (M, N, 4): an image with RGBA values (0-1 float or 0-255 int),i.e. including transparency.

The first two dimensions (M, N) define the rows and columns ofthe image.

This parameter can only be passed positionally.

X, Ytuple or array-like, default:(0,N),(0,M)

X andY are used to specify the coordinates of thequadrilaterals. There are different ways to do this:

  • Use tuplesX=(xmin,xmax) andY=(ymin,ymax) to defineauniform rectangular grid.

    The tuples define the outer edges of the grid. All individualquadrilaterals will be of the same size. This is the fastestversion.

  • Use 1D arraysX,Y to specify anon-uniform rectangulargrid.

    In this caseX andY have to be monotonic 1D arrays of lengthN+1 andM+1, specifying the x and y boundaries of the cells.

    The speed is intermediate. Note: The grid is checked, and iffound to be uniform the fast version is used.

  • Use 2D arraysX,Y if you need anarbitrary quadrilateralgrid (i.e. if the quadrilaterals are not rectangular).

    In this caseX andY are 2D arrays with shape (M + 1, N + 1),specifying the x and y coordinates of the corners of the coloredquadrilaterals.

    This is the most general, but the slowest to render. It mayproduce faster and more compact output using ps, pdf, andsvg backends, however.

These arguments can only be passed positionally.

cmapstr orColormap, default:rcParams["image.cmap"] (default:'viridis')

The Colormap instance or registered colormap name used to map scalar datato colors.

This parameter is ignored ifC is RGB(A).

normstr orNormalize, optional

The normalization method used to scale scalar data to the [0, 1] rangebefore mapping to colors usingcmap. By default, a linear scaling isused, mapping the lowest value to 0 and the highest to 1.

If given, this can be one of the following:

This parameter is ignored ifC is RGB(A).

vmin, vmaxfloat, optional

When using scalar data and no explicitnorm,vmin andvmax definethe data range that the colormap covers. By default, the colormap coversthe complete value range of the supplied data. It is an error to usevmin/vmax when anorm instance is given (but using astrnormname together withvmin/vmax is acceptable).

This parameter is ignored ifC is RGB(A).

colorizerColorizer or None, default: None

The Colorizer object used to map color to data. If None, a Colorizerobject is created from anorm andcmap.

This parameter is ignored ifC is RGB(A).

alphafloat, default: None

The alpha blending value, between 0 (transparent) and 1 (opaque).

snapbool, default: False

Whether to snap the mesh to pixel boundaries.

Returns:
AxesImage orPcolorImage orQuadMesh

The return type depends on the type of grid:

Other Parameters:
dataindexable object, optional

If given, all parameters also accept a strings, which isinterpreted asdata[s] ifs is a key indata.

**kwargs

Supported additional parameters depend on the type of grid.See return types ofimage for further description.

Examples usingmatplotlib.axes.Axes.pcolorfast#

pcolor images

pcolor images