@@ -5596,62 +5596,73 @@ def _pcolorargs(funcname, *args, **kw):
5596
5596
@docstring .dedent_interpd
5597
5597
def pcolor (self , * args , ** kwargs ):
5598
5598
"""
5599
- Create a pseudocolor plot of a 2-D array .
5599
+ Create a pseudocolor plot with a non-regular rectangular grid .
5600
5600
5601
- Call signatures::
5601
+ Call signature::
5602
+
5603
+ pcolor([X, Y,] C, **kwargs)
5604
+
5605
+ *X* and *Y* can be used to specify the corners of the quadrilaterals.
5602
5606
5603
- pcolor(C, **kwargs)
5604
- pcolor(X, Y, C, **kwargs)
5607
+ .. hint::
5605
5608
5606
- pcolor can be very slow for large arrays; consider
5607
- using the similar but much faster
5608
- :func:`~matplotlib.pyplot.pcolormesh` instead.
5609
+ ``pcolor()`` can be very slow for large arrays. In most
5610
+ cases you should use the the similar but much faster
5611
+ `~.Axes.pcolormesh` instead. See there for a discussion of the
5612
+ differences.
5609
5613
5610
5614
Parameters
5611
5615
----------
5612
5616
C : array_like
5613
- An array of color values.
5617
+ A scalar 2-D array. The values will be color-mapped .
5614
5618
5615
5619
X, Y : array_like, optional
5616
- If given, specify the (x, y) coordinates of the colored
5617
- quadrilaterals; the quadrilateral for ``C[i,j]`` has corners at::
5620
+ The coordinates of the quadrilateral corners. The quadrilateral
5621
+ for ``C[i,j]`` has corners at::
5618
5622
5619
- (X[i, j], Y[i, j]),
5620
- (X[i, j+1], Y[i, j+1]),
5621
- (X[i+1, j], Y[i+1, j]),
5622
- (X[i+1, j+1], Y[i+1, j+1])
5623
-
5624
- Ideally the dimensions of ``X`` and ``Y`` should be one greater
5625
- than those of ``C``; if the dimensions are the same, then the last
5626
- row and column of ``C`` will be ignored.
5623
+ (X[i+1, j], Y[i+1, j]) (X[i+1, j+1], Y[i+1, j+1])
5624
+ +--------+
5625
+ | C[i,j] |
5626
+ +--------+
5627
+ (X[i, j], Y[i, j]) (X[i, j+1], Y[i, j+1]),
5627
5628
5628
5629
Note that the column index corresponds to the
5629
- x-coordinate, and the row index corresponds to y; for
5630
- details, see the :ref:`Grid Orientation
5631
- <axes-pcolor-grid-orientation>` section below.
5630
+ x-coordinate, and the row index corresponds to y. For
5631
+ details, see the :ref:`Notes <axes-pcolor-grid-orientation>`
5632
+ section below.
5632
5633
5633
- If either or both of ``X`` and ``Y`` are 1-D arrays or column
5634
- vectors, they will be expanded as needed into the appropriate 2-D
5635
- arrays, making a rectangular grid .
5634
+ The dimensions of *X* and *Y* should be one greater than those of
5635
+ *C*. Alternatively, *X*, *Y* and *C* may have equal dimensions, in
5636
+ which case the last row and column of *C* will be ignored .
5636
5637
5637
- cmap : `~matplotlib.colors.Colormap`, optional, default: None
5638
- If `None`, default to rc settings.
5638
+ If *X* and/or *Y* are 1-D arrays or column vectors they will be
5639
+ expanded as needed into the appropriate 2-D arrays, making a
5640
+ rectangular grid.
5641
+
5642
+ cmap : str or `~matplotlib.colors.Colormap`, optional
5643
+ A Colormap instance or registered colormap name. The colormap
5644
+ maps the *C* values to colors. Defaults to :rc:`image.cmap`.
5639
5645
5640
- norm : `matplotlib.colors.Normalize`, optional, default: None
5641
- An instance is used to scale luminance data to (0, 1).
5642
- If `None`, defaults to :func:`normalize`.
5646
+ norm : `~matplotlib.colors.Normalize`, optional
5647
+ The Normalize instance scales the data values to the canonical
5648
+ colormap range [0, 1] for mapping to colors. By default, the data
5649
+ range is mapped to the colorbar range using linear scaling.
5643
5650
5644
5651
vmin, vmax : scalar, optional, default: None
5645
- ``vmin`` and ``vmax`` are used in conjunction with ``norm`` to
5646
- normalize luminance data. If either is `None`, it is autoscaled to
5647
- the respective min or max of the color array ``C``. If not `None`,
5648
- ``vmin`` or ``vmax`` passed in here override any pre-existing
5649
- values supplied in the ``norm`` instance.
5652
+ The colorbar range. If *None*, suitable min/max values are
5653
+ automatically chosen by the `~.Normalize` instance (defaults to
5654
+ the respective min/max values of *C* in case of the default linear
5655
+ scaling).
5656
+
5657
+ edgecolors : {'none', None, color, color sequence}, optional
5658
+ The color of the edges. Defaults to 'none'. Possible values:
5659
+
5660
+ - 'none' or '': No edge.
5661
+ - *None*: :rc:`patch.edgecolor` will be used. Note that currently
5662
+ :rc:`patch.force_edgecolor` has to be True for this to work.
5663
+ - An mpl color or sequence of colors will set the edge color.
5650
5664
5651
- edgecolors : {None, 'none', color, color sequence}
5652
- If None, the rc setting is used by default.
5653
- If 'none', edges will not be visible.
5654
- An mpl color or sequence of colors will set the edge color.
5665
+ The singular form *edgecolor* works as an alias.
5655
5666
5656
5667
alpha : scalar, optional, default: None
5657
5668
The alpha blending value, between 0 (transparent) and 1 (opaque).
@@ -5666,72 +5677,54 @@ def pcolor(self, *args, **kwargs):
5666
5677
Other Parameters
5667
5678
----------------
5668
5679
antialiaseds : bool, optional, default: False
5669
- The default `` antialiaseds`` is False if the default
5670
- `` edgecolors="none"`` is used. This eliminates artificial lines
5680
+ The default * antialiaseds* is False if the default
5681
+ * edgecolors*\ ="none" is used. This eliminates artificial lines
5671
5682
at patch boundaries, and works regardless of the value of alpha.
5672
- If `` edgecolors`` is not "none", then the default `` antialiaseds``
5683
+ If * edgecolors* is not "none", then the default * antialiaseds*
5673
5684
is taken from :rc:`patch.antialiased`, which defaults to True.
5674
- Stroking the edges may be preferred if `` alpha`` is 1, but will
5685
+ Stroking the edges may be preferred if * alpha* is 1, but will
5675
5686
cause artifacts otherwise.
5676
5687
5677
5688
**kwargs :
5678
-
5679
- Any unused keyword arguments are passed along to the
5680
- `~matplotlib.collections.PolyCollection` constructor:
5689
+ Additionally, the following arguments are allowed. They are passed
5690
+ along to the `~matplotlib.collections.PolyCollection` constructor:
5681
5691
5682
5692
%(PolyCollection)s
5683
5693
5684
5694
See Also
5685
5695
--------
5686
5696
pcolormesh : for an explanation of the differences between
5687
5697
pcolor and pcolormesh.
5698
+ imshow : If *X* and *Y* are each equidistant, `~.Axes.imshow` can be a
5699
+ faster alternative.
5688
5700
5689
5701
Notes
5690
5702
-----
5691
- .. _axes-pcolor-grid-orientation:
5692
-
5693
- ``X``, ``Y`` and ``C`` may be masked arrays. If either C[i, j], or one
5694
- of the vertices surrounding C[i,j] (``X`` or ``Y`` at [i, j], [i+1, j],
5695
- [i, j+1], [i+1, j+1]) is masked, nothing is plotted.
5696
-
5697
- The grid orientation follows the MATLAB convention: an array ``C`` with
5698
- shape (nrows, ncolumns) is plotted with the column number as ``X`` and
5699
- the row number as ``Y``, increasing up; hence it is plotted the way the
5700
- array would be printed, except that the ``Y`` axis is reversed. That
5701
- is, ``C`` is taken as ``C`` (y, x).
5702
-
5703
- Similarly for :func:`meshgrid`::
5704
5703
5705
- x = np.arange(5)
5706
- y = np.arange(3)
5707
- X, Y = np.meshgrid(x, y)
5704
+ **Masked arrays**
5708
5705
5709
- is equivalent to::
5706
+ *X*, *Y* and *C* may be masked arrays. If either ``C[i, j]``, or one
5707
+ of the vertices surrounding ``C[i,j]`` (*X* or *Y* at
5708
+ ``[i, j], [i+1, j], [i, j+1], [i+1, j+1]``) is masked, nothing is
5709
+ plotted.
5710
5710
5711
- X = array([[0, 1, 2, 3, 4],
5712
- [0, 1, 2, 3, 4],
5713
- [0, 1, 2, 3, 4]])
5714
-
5715
- Y = array([[0, 0, 0, 0, 0],
5716
- [1, 1, 1, 1, 1],
5717
- [2, 2, 2, 2, 2]])
5718
-
5719
- so if you have::
5720
-
5721
- C = rand(len(x), len(y))
5711
+ .. _axes-pcolor-grid-orientation:
5722
5712
5723
- then you need to transpose C::
5713
+ **Grid orientation**
5724
5714
5725
- pcolor(X, Y, C.T)
5715
+ The grid orientation follows the standard matrix convention: An array
5716
+ *C* with shape (nrows, ncolumns) is plotted with the column number as
5717
+ *X* and the row number as *Y*.
5726
5718
5727
- or::
5719
+ **Handling of pcolor() end-cases**
5728
5720
5729
- pcolor(C.T)
5721
+ ``pcolor()`` displays all columns of *C* if *X* and *Y* are not
5722
+ specified, or if *X* and *Y* have one more column than *C*.
5723
+ If *X* and *Y* have the same number of columns as *C* then the last
5724
+ column of *C* is dropped. Similarly for the rows.
5730
5725
5731
- MATLAB :func:`pcolor` always discards the last row and column of ``C``,
5732
- but Matplotlib displays the last row and column if ``X`` and ``Y`` are
5733
- not specified, or if ``X`` and ``Y`` have one more row and column than
5734
- ``C``.
5726
+ Note: This behavior is different from MATLAB's ``pcolor()``, which
5727
+ always discards the last row and column of *C*.
5735
5728
"""
5736
5729
5737
5730
if not self ._hold :
0 commit comments