Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 85ace31

Browse files
phobsonMeeseeksDev[bot]
authored and
MeeseeksDev[bot]
committed
Backport PR #11363: Improve docstring of Axes.pcolorfast
1 parent 3f1b92b commit 85ace31

File tree

1 file changed

+73
-55
lines changed

1 file changed

+73
-55
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 73 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -6070,14 +6070,7 @@ def pcolormesh(self, *args, **kwargs):
60706070
@docstring.dedent_interpd
60716071
def pcolorfast(self, *args, **kwargs):
60726072
"""
6073-
pseudocolor plot of a 2-D array
6074-
6075-
Experimental; this is a pcolor-type method that
6076-
provides the fastest possible rendering with the Agg
6077-
backend, and that can handle any quadrilateral grid.
6078-
It supports only flat shading (no outlines), it lacks
6079-
support for log scaling of the axes, and it does not
6080-
have a pyplot wrapper.
6073+
Create a pseudocolor plot with a non-regular rectangular grid.
60816074
60826075
Call signatures::
60836076
@@ -6086,68 +6079,93 @@ def pcolorfast(self, *args, **kwargs):
60866079
ax.pcolorfast(x, y, C, **kwargs)
60876080
ax.pcolorfast(X, Y, C, **kwargs)
60886081
6089-
C is the 2D array of color values corresponding to quadrilateral
6090-
cells. Let (nr, nc) be its shape. C may be a masked array.
6082+
This method is similar to ~.Axes.pcolor` and `~.Axes.pcolormesh`.
6083+
It's designed to provide the fastest pcolor-type plotting with the
6084+
Agg backend. To achieve this, it uses different algorithms internally
6085+
depending on the complexity of the input grid (regular rectangular,
6086+
non-regular rectangular or arbitrary quadrilateral).
6087+
6088+
.. warning::
6089+
6090+
This method is experimental. Compared to `~.Axes.pcolor` or
6091+
`~.Axes.pcolormesh` it has some limitations:
6092+
6093+
- It supports only flat shading (no outlines)
6094+
- It lacks support for log scaling of the axes.
6095+
- It does not have a have a pyplot wrapper.
6096+
6097+
Parameters
6098+
----------
6099+
C : array-like(M, N)
6100+
A scalar 2D array. The values will be color-mapped.
6101+
*C* may be a masked array.
6102+
6103+
x, y : tuple or array-like
6104+
*X* and *Y* are used to specify the coordinates of the
6105+
quadilaterals. There are different ways to do this:
6106+
6107+
- Use tuples ``xr=(xmin, xmax)`` and ``yr=(ymin, ymax)`` to define
6108+
a *uniform rectiangular grid*.
60916109
6092-
``ax.pcolorfast(C, **kwargs)`` is equivalent to
6093-
``ax.pcolorfast([0,nc], [0,nr], C, **kwargs)``
6110+
The tuples define the outer edges of the grid. All individual
6111+
quadrilaterals will be of the same size. This is the fastest
6112+
version.
60946113
6095-
*xr*, *yr* specify the ranges of *x* and *y* corresponding to the
6096-
rectangular region bounding *C*. If::
6114+
- Use 1D arrays *x*, *y* to specify a *non-uniform rectangular
6115+
grid*.
60976116
6098-
xr = [x0, x1]
6117+
In this case *x* and *y* have to be monotonic 1D arrays of length
6118+
*N+1* and *M+1*, specifying the x and y boundaries of the cells.
60996119
6100-
and::
6120+
The speed is intermediate. Note: The grid is checked, and if
6121+
found to be uniform the fast version is used.
61016122
6102-
yr = [y0,y1]
6123+
- Use 2D arrays *X*, *Y* if you need an *arbitrary quadrilateral
6124+
grid* (i.e. if the quadrilaterals are not rectangular).
61036125
6104-
then *x* goes from *x0* to *x1* as the second index of *C* goes
6105-
from 0 to *nc*, etc. (*x0*, *y0*) is the outermost corner of
6106-
cell (0,0), and (*x1*, *y1*) is the outermost corner of cell
6107-
(*nr*-1, *nc*-1). All cells are rectangles of the same size.
6108-
This is the fastest version.
6126+
In this case *X* and *Y* are 2D arrays with shape (M, N),
6127+
specifying the x and y coordinates of the corners of the colored
6128+
quadrilaterals. See `~.Axes.pcolormesh` for details.
61096129
6110-
*x*, *y* are monotonic 1D arrays of length *nc* +1 and *nr* +1,
6111-
respectively, giving the x and y boundaries of the cells. Hence
6112-
the cells are rectangular but the grid may be nonuniform. The
6113-
speed is intermediate. (The grid is checked, and if found to be
6114-
uniform the fast version is used.)
6130+
This is the most general, but the slowest to render. It may
6131+
produce faster and more compact output using ps, pdf, and
6132+
svg backends, however.
61156133
6116-
*X* and *Y* are 2D arrays with shape (*nr* +1, *nc* +1) that specify
6117-
the (x,y) coordinates of the corners of the colored
6118-
quadrilaterals; the quadrilateral for C[i,j] has corners at
6119-
(X[i,j],Y[i,j]), (X[i,j+1],Y[i,j+1]), (X[i+1,j],Y[i+1,j]),
6120-
(X[i+1,j+1],Y[i+1,j+1]). The cells need not be rectangular.
6121-
This is the most general, but the slowest to render. It may
6122-
produce faster and more compact output using ps, pdf, and
6123-
svg backends, however.
6134+
Leaving out *x* and *y* defaults to ``xr=(0, N)``, ``yr=(O, M)``.
6135+
6136+
cmap : str or `~matplotlib.colors.Colormap`, optional
6137+
A Colormap instance or registered colormap name. The colormap
6138+
maps the *C* values to colors. Defaults to :rc:`image.cmap`.
61246139
6125-
Note that the column index corresponds to the x-coordinate,
6126-
and the row index corresponds to y; for details, see
6127-
:ref:`Grid Orientation <axes-pcolor-grid-orientation>`.
6140+
norm : `~matplotlib.colors.Normalize`, optional
6141+
The Normalize instance scales the data values to the canonical
6142+
colormap range [0, 1] for mapping to colors. By default, the data
6143+
range is mapped to the colorbar range using linear scaling.
61286144
6129-
Optional keyword arguments:
6145+
vmin, vmax : scalar, optional, default: None
6146+
The colorbar range. If *None*, suitable min/max values are
6147+
automatically chosen by the `~.Normalize` instance (defaults to
6148+
the respective min/max values of *C* in case of the default linear
6149+
scaling).
61306150
6131-
*cmap*: [ *None* | Colormap ]
6132-
A :class:`matplotlib.colors.Colormap` instance from cm. If *None*,
6133-
use rc settings.
6151+
alpha : scalar, optional, default: None
6152+
The alpha blending value, between 0 (transparent) and 1 (opaque).
61346153
6135-
*norm*: [ *None* | Normalize ]
6136-
A :class:`matplotlib.colors.Normalize` instance is used to scale
6137-
luminance data to 0,1. If *None*, defaults to normalize()
6154+
snap : bool, optional, default: False
6155+
Whether to snap the mesh to pixel boundaries.
61386156
6139-
*vmin*/*vmax*: [ *None* | scalar ]
6140-
*vmin* and *vmax* are used in conjunction with norm to normalize
6141-
luminance data. If either are *None*, the min and max
6142-
of the color array *C* is used. If you pass a norm instance,
6143-
*vmin* and *vmax* will be *None*.
6157+
Returns
6158+
-------
6159+
image : `.AxesImage` or `.PcolorImage` or `.QuadMesh`
6160+
The return type depends on the type of grid:
61446161
6145-
*alpha*: ``0 <= scalar <= 1`` or *None*
6146-
the alpha blending value
6162+
- `.AxesImage` for a regular rectangular grid.
6163+
- `.PcolorImage` for a non-regular rectangular grid.
6164+
- `.QuadMesh` for a non-rectangular grid.
61476165
6148-
Return value is an image if a regular or rectangular grid
6149-
is specified, and a :class:`~matplotlib.collections.QuadMesh`
6150-
collection in the general quadrilateral case.
6166+
Notes
6167+
-----
6168+
.. [notes section required to get data note injection right]
61516169
61526170
"""
61536171

0 commit comments

Comments
 (0)