@@ -5268,62 +5268,73 @@ def _pcolorargs(funcname, *args, allmatch=False):
5268
5268
def pcolor (self , * args , alpha = None , norm = None , cmap = None , vmin = None ,
5269
5269
vmax = None , ** kwargs ):
5270
5270
"""
5271
- Create a pseudocolor plot of a 2-D array .
5271
+ Create a pseudocolor plot with a non-regular rectangular grid .
5272
5272
5273
- Call signatures ::
5273
+ Call signature ::
5274
5274
5275
- pcolor(C, **kwargs)
5276
- pcolor(X, Y, C, **kwargs)
5275
+ pcolor([X, Y,] C, **kwargs)
5277
5276
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.
5281
5285
5282
5286
Parameters
5283
5287
----------
5284
5288
C : array_like
5285
- An array of color values.
5289
+ A scalar 2-D array. The values will be color-mapped .
5286
5290
5287
5291
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::
5295
5294
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]),
5299
5300
5300
5301
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.
5304
5305
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 .
5308
5309
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`.
5311
5317
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.
5315
5322
5316
5323
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:
5322
5331
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.
5327
5338
5328
5339
alpha : scalar, optional, default: None
5329
5340
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,
5338
5349
Other Parameters
5339
5350
----------------
5340
5351
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
5343
5354
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*
5345
5356
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
5347
5358
cause artifacts otherwise.
5348
5359
5349
5360
**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:
5353
5363
5354
5364
%(PolyCollection)s
5355
5365
5356
5366
See Also
5357
5367
--------
5358
5368
pcolormesh : for an explanation of the differences between
5359
5369
pcolor and pcolormesh.
5370
+ imshow : If *X* and *Y* are each equidistant, `~.Axes.imshow` can be a
5371
+ faster alternative.
5360
5372
5361
5373
Notes
5362
5374
-----
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`::
5376
5375
5377
- x = np.arange(5)
5378
- y = np.arange(3)
5379
- X, Y = np.meshgrid(x, y)
5376
+ **Masked arrays**
5380
5377
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.
5382
5382
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:
5394
5384
5395
- then you need to transpose C::
5385
+ **Grid orientation**
5396
5386
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*.
5398
5390
5399
- or::
5391
+ **Handling of pcolor() end-cases**
5400
5392
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.
5402
5397
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*.
5407
5400
"""
5408
5401
X , Y , C = self ._pcolorargs ('pcolor' , * args , allmatch = False )
5409
5402
Ny , Nx = X .shape
0 commit comments