@@ -5268,62 +5268,73 @@ def _pcolorargs(funcname, *args, allmatch=False):
52685268 def pcolor (self , * args , alpha = None , norm = None , cmap = None , vmin = None ,
52695269 vmax = None , ** kwargs ):
52705270 """
5271- Create a pseudocolor plot of a 2-D array .
5271+ Create a pseudocolor plot with a non-regular rectangular grid .
52725272
5273- Call signatures ::
5273+ Call signature ::
52745274
5275- pcolor(C, **kwargs)
5276- pcolor(X, Y, C, **kwargs)
5275+ pcolor([X, Y,] C, **kwargs)
52775276
5278- pcolor can be very slow for large arrays; consider
5279- using the similar but much faster
5280- :func:`~matplotlib.pyplot.pcolormesh` instead.
5277+ *X* and *Y* can be used to specify the corners of the quadrilaterals.
5278+
5279+ .. hint::
5280+
5281+ ``pcolor()`` can be very slow for large arrays. In most
5282+ cases you should use the the similar but much faster
5283+ `~.Axes.pcolormesh` instead. See there for a discussion of the
5284+ differences.
52815285
52825286 Parameters
52835287 ----------
52845288 C : array_like
5285- An array of color values.
5289+ A scalar 2-D array. The values will be color-mapped .
52865290
52875291 X, Y : array_like, optional
5288- If given, specify the (x, y) coordinates of the colored
5289- quadrilaterals; the quadrilateral for ``C[i,j]`` has corners at::
5290-
5291- (X[i, j], Y[i, j]),
5292- (X[i, j+1], Y[i, j+1]),
5293- (X[i+1, j], Y[i+1, j]),
5294- (X[i+1, j+1], Y[i+1, j+1])
5292+ The coordinates of the quadrilateral corners. The quadrilateral
5293+ for ``C[i,j]`` has corners at::
52955294
5296- Ideally the dimensions of ``X`` and ``Y`` should be one greater
5297- than those of ``C``; if the dimensions are the same, then the last
5298- row and column of ``C`` will be ignored.
5295+ (X[i+1, j], Y[i+1, j]) (X[i+1, j+1], Y[i+1, j+1])
5296+ +--------+
5297+ | C[i,j] |
5298+ +--------+
5299+ (X[i, j], Y[i, j]) (X[i, j+1], Y[i, j+1]),
52995300
53005301 Note that the column index corresponds to the
5301- x-coordinate, and the row index corresponds to y; for
5302- details, see the :ref:`Grid Orientation
5303- <axes-pcolor-grid-orientation>` section below.
5302+ x-coordinate, and the row index corresponds to y. For
5303+ details, see the :ref:`Notes <axes-pcolor-grid-orientation>`
5304+ section below.
53045305
5305- If either or both of ``X`` and ``Y`` are 1-D arrays or column
5306- vectors, they will be expanded as needed into the appropriate 2-D
5307- arrays, making a rectangular grid .
5306+ The dimensions of *X* and *Y* should be one greater than those of
5307+ *C*. Alternatively, *X*, *Y* and *C* may have equal dimensions, in
5308+ which case the last row and column of *C* will be ignored .
53085309
5309- cmap : `~matplotlib.colors.Colormap`, optional, default: None
5310- If `None`, default to rc settings.
5310+ If *X* and/or *Y* are 1-D arrays or column vectors they will be
5311+ expanded as needed into the appropriate 2-D arrays, making a
5312+ rectangular grid.
5313+
5314+ cmap : str or `~matplotlib.colors.Colormap`, optional
5315+ A Colormap instance or registered colormap name. The colormap
5316+ maps the *C* values to colors. Defaults to :rc:`image.cmap`.
53115317
5312- norm : `matplotlib.colors.Normalize`, optional, default: None
5313- An instance is used to scale luminance data to (0, 1).
5314- If `None`, defaults to :func:`normalize`.
5318+ norm : `~matplotlib.colors.Normalize`, optional
5319+ The Normalize instance scales the data values to the canonical
5320+ colormap range [0, 1] for mapping to colors. By default, the data
5321+ range is mapped to the colorbar range using linear scaling.
53155322
53165323 vmin, vmax : scalar, optional, default: None
5317- ``vmin`` and ``vmax`` are used in conjunction with ``norm`` to
5318- normalize luminance data. If either is `None`, it is autoscaled to
5319- the respective min or max of the color array ``C``. If not `None`,
5320- ``vmin`` or ``vmax`` passed in here override any pre-existing
5321- values supplied in the ``norm`` instance.
5324+ The colorbar range. If *None*, suitable min/max values are
5325+ automatically chosen by the `~.Normalize` instance (defaults to
5326+ the respective min/max values of *C* in case of the default linear
5327+ scaling).
5328+
5329+ edgecolors : {'none', None, color, color sequence}, optional
5330+ The color of the edges. Defaults to 'none'. Possible values:
53225331
5323- edgecolors : {None, 'none', color, color sequence}
5324- If None, the rc setting is used by default.
5325- If 'none', edges will not be visible.
5326- An mpl color or sequence of colors will set the edge color.
5332+ - 'none' or '': No edge.
5333+ - *None*: :rc:`patch.edgecolor` will be used. Note that currently
5334+ :rc:`patch.force_edgecolor` has to be True for this to work.
5335+ - An mpl color or sequence of colors will set the edge color.
5336+
5337+ The singular form *edgecolor* works as an alias.
53275338
53285339 alpha : scalar, optional, default: None
53295340 The alpha blending value, between 0 (transparent) and 1 (opaque).
@@ -5338,72 +5349,54 @@ def pcolor(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
53385349 Other Parameters
53395350 ----------------
53405351 antialiaseds : bool, optional, default: False
5341- The default `` antialiaseds`` is False if the default
5342- `` edgecolors="none"`` is used. This eliminates artificial lines
5352+ The default * antialiaseds* is False if the default
5353+ * edgecolors*\ ="none" is used. This eliminates artificial lines
53435354 at patch boundaries, and works regardless of the value of alpha.
5344- If `` edgecolors`` is not "none", then the default `` antialiaseds``
5355+ If * edgecolors* is not "none", then the default * antialiaseds*
53455356 is taken from :rc:`patch.antialiased`, which defaults to True.
5346- Stroking the edges may be preferred if `` alpha`` is 1, but will
5357+ Stroking the edges may be preferred if * alpha* is 1, but will
53475358 cause artifacts otherwise.
53485359
53495360 **kwargs :
5350-
5351- Any unused keyword arguments are passed along to the
5352- `~matplotlib.collections.PolyCollection` constructor:
5361+ Additionally, the following arguments are allowed. They are passed
5362+ along to the `~matplotlib.collections.PolyCollection` constructor:
53535363
53545364 %(PolyCollection)s
53555365
53565366 See Also
53575367 --------
53585368 pcolormesh : for an explanation of the differences between
53595369 pcolor and pcolormesh.
5370+ imshow : If *X* and *Y* are each equidistant, `~.Axes.imshow` can be a
5371+ faster alternative.
53605372
53615373 Notes
53625374 -----
5363- .. _axes-pcolor-grid-orientation:
5364-
5365- ``X``, ``Y`` and ``C`` may be masked arrays. If either C[i, j], or one
5366- of the vertices surrounding C[i,j] (``X`` or ``Y`` at [i, j], [i+1, j],
5367- [i, j+1], [i+1, j+1]) is masked, nothing is plotted.
5368-
5369- The grid orientation follows the MATLAB convention: an array ``C`` with
5370- shape (nrows, ncolumns) is plotted with the column number as ``X`` and
5371- the row number as ``Y``, increasing up; hence it is plotted the way the
5372- array would be printed, except that the ``Y`` axis is reversed. That
5373- is, ``C`` is taken as ``C`` (y, x).
5374-
5375- Similarly for :func:`meshgrid`::
53765375
5377- x = np.arange(5)
5378- y = np.arange(3)
5379- X, Y = np.meshgrid(x, y)
5376+ **Masked arrays**
53805377
5381- is equivalent to::
5378+ *X*, *Y* and *C* may be masked arrays. If either ``C[i, j]``, or one
5379+ of the vertices surrounding ``C[i,j]`` (*X* or *Y* at
5380+ ``[i, j], [i+1, j], [i, j+1], [i+1, j+1]``) is masked, nothing is
5381+ plotted.
53825382
5383- X = array([[0, 1, 2, 3, 4],
5384- [0, 1, 2, 3, 4],
5385- [0, 1, 2, 3, 4]])
5386-
5387- Y = array([[0, 0, 0, 0, 0],
5388- [1, 1, 1, 1, 1],
5389- [2, 2, 2, 2, 2]])
5390-
5391- so if you have::
5392-
5393- C = rand(len(x), len(y))
5383+ .. _axes-pcolor-grid-orientation:
53945384
5395- then you need to transpose C::
5385+ **Grid orientation**
53965386
5397- pcolor(X, Y, C.T)
5387+ The grid orientation follows the standard matrix convention: An array
5388+ *C* with shape (nrows, ncolumns) is plotted with the column number as
5389+ *X* and the row number as *Y*.
53985390
5399- or::
5391+ **Handling of pcolor() end-cases**
54005392
5401- pcolor(C.T)
5393+ ``pcolor()`` displays all columns of *C* if *X* and *Y* are not
5394+ specified, or if *X* and *Y* have one more column than *C*.
5395+ If *X* and *Y* have the same number of columns as *C* then the last
5396+ column of *C* is dropped. Similarly for the rows.
54025397
5403- MATLAB :func:`pcolor` always discards the last row and column of ``C``,
5404- but Matplotlib displays the last row and column if ``X`` and ``Y`` are
5405- not specified, or if ``X`` and ``Y`` have one more row and column than
5406- ``C``.
5398+ Note: This behavior is different from MATLAB's ``pcolor()``, which
5399+ always discards the last row and column of *C*.
54075400 """
54085401 X , Y , C = self ._pcolorargs ('pcolor' , * args , allmatch = False )
54095402 Ny , Nx = X .shape
0 commit comments