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

Skip to content

Commit 3e14dd2

Browse files
committed
Improve docstring of Axes.pcolorfast
1 parent 391c0cb commit 3e14dd2

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
@@ -5718,14 +5718,7 @@ def pcolormesh(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
57185718
def pcolorfast(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
57195719
vmax=None, **kwargs):
57205720
"""
5721-
pseudocolor plot of a 2-D array
5722-
5723-
Experimental; this is a pcolor-type method that
5724-
provides the fastest possible rendering with the Agg
5725-
backend, and that can handle any quadrilateral grid.
5726-
It supports only flat shading (no outlines), it lacks
5727-
support for log scaling of the axes, and it does not
5728-
have a pyplot wrapper.
5721+
Create a pseudocolor plot with a non-regular rectangular grid.
57295722
57305723
Call signatures::
57315724
@@ -5734,68 +5727,93 @@ def pcolorfast(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
57345727
ax.pcolorfast(x, y, C, **kwargs)
57355728
ax.pcolorfast(X, Y, C, **kwargs)
57365729
5737-
C is the 2D array of color values corresponding to quadrilateral
5738-
cells. Let (nr, nc) be its shape. C may be a masked array.
5730+
This method is similar to ~.Axes.pcolor` and `~.Axes.pcolormesh`.
5731+
It's designed to provide the fastest pcolor-type plotting with the
5732+
Agg backend. To achieve this, it uses different algorithms internally
5733+
depending on the complexity of the input grid (regular rectangular,
5734+
non-regular rectangular or arbitrary quadrilateral).
5735+
5736+
.. warning::
5737+
5738+
This method is experimental. Compared to `~.Axes.pcolor` or
5739+
`~.Axes.pcolormesh` it has some limitations:
5740+
5741+
- It supports only flat shading (no outlines)
5742+
- It lacks support for log scaling of the axes.
5743+
- It does not have a have a pyplot wrapper.
5744+
5745+
Parameters
5746+
----------
5747+
C : array-like(M, N)
5748+
A scalar 2D array. The values will be color-mapped.
5749+
*C* may be a masked array.
5750+
5751+
x, y : tuple or array-like
5752+
*X* and *Y* are used to specify the coordinates of the
5753+
quadilaterals. There are different ways to do this:
5754+
5755+
- Use tuples ``xr=(xmin, xmax)`` and ``yr=(ymin, ymax)`` to define
5756+
a *uniform rectiangular grid*.
57395757
5740-
``ax.pcolorfast(C, **kwargs)`` is equivalent to
5741-
``ax.pcolorfast([0,nc], [0,nr], C, **kwargs)``
5758+
The tuples define the outer edges of the grid. All individual
5759+
quadrilaterals will be of the same size. This is the fastest
5760+
version.
57425761
5743-
*xr*, *yr* specify the ranges of *x* and *y* corresponding to the
5744-
rectangular region bounding *C*. If::
5762+
- Use 1D arrays *x*, *y* to specify a *non-uniform rectangular
5763+
grid*.
57455764
5746-
xr = [x0, x1]
5765+
In this case *x* and *y* have to be monotonic 1D arrays of length
5766+
*N+1* and *M+1*, specifying the x and y boundaries of the cells.
57475767
5748-
and::
5768+
The speed is intermediate. Note: The grid is checked, and if
5769+
found to be uniform the fast version is used.
57495770
5750-
yr = [y0,y1]
5771+
- Use 2D arrays *X*, *Y* if you need an *arbitrary quadrilateral
5772+
grid* (i.e. if the quadrilaterals are not rectangular).
57515773
5752-
then *x* goes from *x0* to *x1* as the second index of *C* goes
5753-
from 0 to *nc*, etc. (*x0*, *y0*) is the outermost corner of
5754-
cell (0,0), and (*x1*, *y1*) is the outermost corner of cell
5755-
(*nr*-1, *nc*-1). All cells are rectangles of the same size.
5756-
This is the fastest version.
5774+
In this case *X* and *Y* are 2D arrays with shape (M, N),
5775+
specifying the x and y coordinates of the corners of the colored
5776+
quadrilaterals. See `~.Axes.pcolormesh` for details.
57575777
5758-
*x*, *y* are monotonic 1D arrays of length *nc* +1 and *nr* +1,
5759-
respectively, giving the x and y boundaries of the cells. Hence
5760-
the cells are rectangular but the grid may be nonuniform. The
5761-
speed is intermediate. (The grid is checked, and if found to be
5762-
uniform the fast version is used.)
5778+
This is the most general, but the slowest to render. It may
5779+
produce faster and more compact output using ps, pdf, and
5780+
svg backends, however.
57635781
5764-
*X* and *Y* are 2D arrays with shape (*nr* +1, *nc* +1) that specify
5765-
the (x,y) coordinates of the corners of the colored
5766-
quadrilaterals; the quadrilateral for C[i,j] has corners at
5767-
(X[i,j],Y[i,j]), (X[i,j+1],Y[i,j+1]), (X[i+1,j],Y[i+1,j]),
5768-
(X[i+1,j+1],Y[i+1,j+1]). The cells need not be rectangular.
5769-
This is the most general, but the slowest to render. It may
5770-
produce faster and more compact output using ps, pdf, and
5771-
svg backends, however.
5782+
Leaving out *x* and *y* defaults to ``xr=(0, N)``, ``yr=(O, M)``.
5783+
5784+
cmap : str or `~matplotlib.colors.Colormap`, optional
5785+
A Colormap instance or registered colormap name. The colormap
5786+
maps the *C* values to colors. Defaults to :rc:`image.cmap`.
57725787
5773-
Note that the column index corresponds to the x-coordinate,
5774-
and the row index corresponds to y; for details, see
5775-
:ref:`Grid Orientation <axes-pcolor-grid-orientation>`.
5788+
norm : `~matplotlib.colors.Normalize`, optional
5789+
The Normalize instance scales the data values to the canonical
5790+
colormap range [0, 1] for mapping to colors. By default, the data
5791+
range is mapped to the colorbar range using linear scaling.
57765792
5777-
Optional keyword arguments:
5793+
vmin, vmax : scalar, optional, default: None
5794+
The colorbar range. If *None*, suitable min/max values are
5795+
automatically chosen by the `~.Normalize` instance (defaults to
5796+
the respective min/max values of *C* in case of the default linear
5797+
scaling).
57785798
5779-
*cmap*: [ *None* | Colormap ]
5780-
A :class:`matplotlib.colors.Colormap` instance from cm. If *None*,
5781-
use rc settings.
5799+
alpha : scalar, optional, default: None
5800+
The alpha blending value, between 0 (transparent) and 1 (opaque).
57825801
5783-
*norm*: [ *None* | Normalize ]
5784-
A :class:`matplotlib.colors.Normalize` instance is used to scale
5785-
luminance data to 0,1. If *None*, defaults to normalize()
5802+
snap : bool, optional, default: False
5803+
Whether to snap the mesh to pixel boundaries.
57865804
5787-
*vmin*/*vmax*: [ *None* | scalar ]
5788-
*vmin* and *vmax* are used in conjunction with norm to normalize
5789-
luminance data. If either are *None*, the min and max
5790-
of the color array *C* is used. If you pass a norm instance,
5791-
*vmin* and *vmax* will be *None*.
5805+
Returns
5806+
-------
5807+
image : `.AxesImage` or `.PcolorImage` or `.QuadMesh`
5808+
The return type depends on the type of grid:
57925809
5793-
*alpha*: ``0 <= scalar <= 1`` or *None*
5794-
the alpha blending value
5810+
- `.AxesImage` for a regular rectangular grid.
5811+
- `.PcolorImage` for a non-regular rectangular grid.
5812+
- `.QuadMesh` for a non-rectangular grid.
57955813
5796-
Return value is an image if a regular or rectangular grid
5797-
is specified, and a :class:`~matplotlib.collections.QuadMesh`
5798-
collection in the general quadrilateral case.
5814+
Notes
5815+
-----
5816+
.. [notes section required to get data note injection right]
57995817
58005818
"""
58015819
if norm is not None and not isinstance(norm, mcolors.Normalize):

0 commit comments

Comments
 (0)