@@ -5654,18 +5654,21 @@ def pcolor(self, *args, **kwargs):
5654
5654
the respective min/max values of *C* in case of the default linear
5655
5655
scaling).
5656
5656
5657
- edgecolors : {'none', None, color, color sequence}, optional
5657
+ edgecolors : {'none', None, 'face', color, color sequence}, optional
5658
5658
The color of the edges. Defaults to 'none'. Possible values:
5659
5659
5660
5660
- 'none' or '': No edge.
5661
5661
- *None*: :rc:`patch.edgecolor` will be used. Note that currently
5662
5662
:rc:`patch.force_edgecolor` has to be True for this to work.
5663
+ - 'face': Use the adjacent face color.
5663
5664
- An mpl color or sequence of colors will set the edge color.
5664
5665
5665
5666
The singular form *edgecolor* works as an alias.
5666
5667
5667
5668
alpha : scalar, optional, default: None
5668
- The alpha blending value, between 0 (transparent) and 1 (opaque).
5669
+ The alpha blending value of the face color, between 0 (transparent)
5670
+ and 1 (opaque). Note: The edgecolor is currently not affected by
5671
+ this.
5669
5672
5670
5673
snap : bool, optional, default: False
5671
5674
Whether to snap the mesh to pixel boundaries.
@@ -5846,79 +5849,160 @@ def pcolor(self, *args, **kwargs):
5846
5849
@docstring .dedent_interpd
5847
5850
def pcolormesh (self , * args , ** kwargs ):
5848
5851
"""
5849
- Plot a quadrilateral mesh .
5852
+ Create a pseudocolor plot with a non-regular rectangular grid .
5850
5853
5851
- Call signatures ::
5854
+ Call signature ::
5852
5855
5853
- pcolormesh(C)
5854
- pcolormesh(X, Y, C)
5855
- pcolormesh(C, **kwargs)
5856
+ pcolor([X, Y,] C, **kwargs)
5856
5857
5857
- Create a pseudocolor plot of a 2-D array .
5858
+ *X* and *Y* can be used to specify the corners of the quadrilaterals .
5858
5859
5859
- pcolormesh is similar to :func:`~matplotlib.pyplot.pcolor`,
5860
- but uses a different mechanism and returns a different
5861
- object; pcolor returns a
5862
- :class:`~matplotlib.collections.PolyCollection` but pcolormesh
5863
- returns a
5864
- :class:`~matplotlib.collections.QuadMesh`. It is much faster,
5865
- so it is almost always preferred for large arrays.
5860
+ .. note::
5866
5861
5867
- *C* may be a masked array, but *X* and *Y* may not. Masked
5868
- array support is implemented via *cmap* and *norm*; in
5869
- contrast, :func:`~matplotlib.pyplot.pcolor` simply does not
5870
- draw quadrilaterals with masked colors or vertices.
5862
+ ``pcolormesh()`` is similar to :func:`~Axes.pcolor`. It's much
5863
+ faster and preferred in most cases. For a detailed discussion on
5864
+ the differences see
5865
+ :ref:`Differences between pcolor() and pcolormesh()
5866
+ <differences-pcolor-pcolormesh>`.
5871
5867
5872
- Other Parameters
5873
- ----------------
5874
- cmap : Colormap, optional
5875
- A :class:`matplotlib.colors.Colormap` instance. If ``None``, use
5876
- rc settings.
5868
+ Parameters
5869
+ ----------
5870
+ C : array_like
5871
+ A scalar 2-D array. The values will be color-mapped.
5877
5872
5878
-
D7AE
norm : Normalize, optional
5879
- A :class:`matplotlib.colors.Normalize` instance is used to
5880
- scale luminance data to 0,1. If ``None``, defaults to
5881
- :func:`normalize`.
5873
+ X, Y : array_like, optional
5874
+ The coordinates of the quadrilateral corners. The quadrilateral
5875
+ for ``C[i,j]`` has corners at::
5882
5876
5883
- vmin, vmax : scalar, optional
5884
- *vmin* and *vmax* are used in conjunction with *norm* to
5885
- normalize luminance data. If either is ``None``, it is autoscaled
5886
- to the respective min or max of the color array *C*.
5887
- If not ``None``, *vmin* or *vmax* passed in here override any
5888
- pre-existing values supplied in the *norm* instance.
5877
+ (X[i+1, j], Y[i+1, j]) (X[i+1, j+1], Y[i+1, j+1])
5878
+ +--------+
5879
+ | C[i,j] |
5880
+ +--------+
5881
+ (X[i, j], Y[i, j]) (X[i, j+1], Y[i, j+1]),
5882
+
5883
+ Note that the column index corresponds to the
5884
+ x-coordinate, and the row index corresponds to y. For
5885
+ details, see the :ref:`Notes <axes-pcolormesh-grid-orientation>`
5886
+ section below.
5887
+
5888
+ The dimensions of *X* and *Y* should be one greater than those of
5889
+ *C*. Alternatively, *X*, *Y* and *C* may have equal dimensions, in
5890
+ which case the last row and column of *C* will be ignored.
5891
+
5892
+ If *X* and/or *Y* are 1-D arrays or column vectors they will be
5893
+ expanded as needed into the appropriate 2-D arrays, making a
5894
+ rectangular grid.
5895
+
5896
+ cmap : str or `~matplotlib.colors.Colormap`, optional
5897
+ A Colormap instance or registered colormap name. The colormap
5898
+ maps the *C* values to colors. Defaults to :rc:`image.cmap`.
5899
+
5900
+ norm : `~matplotlib.colors.Normalize`, optional
5901
+ The Normalize instance scales the data values to the canonical
5902
+ colormap range [0, 1] for mapping to colors. By default, the data
5903
+ range is mapped to the colorbar range using linear scaling.
5904
+
5905
+ vmin, vmax : scalar, optional, default: None
5906
+ The colorbar range. If *None*, suitable min/max values are
5907
+ automatically chosen by the `~.Normalize` instance (defaults to
5908
+ the respective min/max values of *C* in case of the default linear
5909
+ scaling).
5889
5910
5890
- shading : [ 'flat' | 'gouraud' ], optional
5891
- 'flat' indicates a solid color for each quad. When
5892
- 'gouraud', each quad will be Gouraud shaded. When gouraud
5893
- shading, *edgecolors* is ignored.
5911
+ edgecolors : {'none', None, 'face', color, color sequence}, optional
5912
+ The color of the edges. Defaults to 'none'. Possible values:
5894
5913
5895
- edgecolors : string, color, color sequence, optional
5896
- - If ``None``, the rc setting is used by default.
5897
- - If ``'None'``, edges will not be visible.
5898
- - If ``'face'``, edges will have the same color as the faces.
5914
+ - 'none' or '': No edge.
5915
+ - *None*: :rc:`patch.edgecolor` will be used. Note that currently
5916
+ :rc:`patch.force_edgecolor` has to be True for this to work.
5917
+ - 'face': Use the adjacent face color.
5918
+ - An mpl color or sequence of colors will set the edge color.
5899
5919
5900
- An mpl color or sequence of colors will also set the edge color .
5920
+ The singular form *edgecolor* works as an alias .
5901
5921
5902
- alpha : scalar, optional
5903
- Alpha blending value. Must be between 0 and 1.
5922
+ alpha : scalar, optional, default: None
5923
+ The alpha blending value, between 0 (transparent) and 1 (opaque).
5924
+
5925
+ shading : {'flat', 'gouraud'}, optional
5926
+ The fill style, Possible values:
5927
+
5928
+ - 'flat': A solid color is used for each quad. The color of the
5929
+ quad (i, j), (i+1, j), (i, j+1), (i+1, j+1) is given by
5930
+ ``C[i,j]``.
5931
+ - 'gouraud': Each quad will be Gouraud shaded: The color of the
5932
+ corners (i', j') are given by ``C[i',j']``. The color values of
5933
+ the area in between is interpolated from the corner values.
5934
+ When Gouraud shading is used, *edgecolors* is ignored.
5935
+
5936
+ snap : bool, optional, default: False
5937
+ Whether to snap the mesh to pixel boundaries.
5904
5938
5905
5939
Returns
5906
5940
-------
5907
- matplotlib.collections.QuadMesh
5941
+ mesh : `matplotlib.collections.QuadMesh`
5942
+
5943
+ Other Parameters
5944
+ ----------------
5945
+ **kwargs
5946
+ Additionally, the following arguments are allowed. They are passed
5947
+ along to the `~matplotlib.collections.QuadMesh` constructor:
5948
+
5949
+ %(QuadMesh)s
5950
+
5908
5951
5909
5952
See Also
5910
5953
--------
5911
- matplotlib.pyplot.pcolor :
5912
- For an explanation of the grid orientation
5913
- (:ref:`Grid Orientation <axes-pcolor-grid-orientation>`)
5914
- and the expansion of 1-D *X* and/or *Y* to 2-D arrays.
5954
+ pcolor : An alternative implementation with slightly different
5955
+ features. For a detailed discussion on the differences see
5956
+ :ref:`Differences between pcolor() and pcolormesh()
5957
+ <differences-pcolor-pcolormesh>`.
5958
+ imshow : If *X* and *Y* are each equidistant, `~.Axes.imshow` can be a
5959
+ faster alternative.
5915
5960
5916
5961
Notes
5917
5962
-----
5918
- kwargs can be used to control the
5919
- :class:`matplotlib.collections.QuadMesh` properties:
5920
5963
5921
- %(QuadMesh)s
5964
+ **Masked arrays**
5965
+
5966
+ *C* may be a masked array. If ``C[i, j]`` is masked, the corresponding
5967
+ quadrilateral will be transparent. Masking of *X* and *Y* is not
5968
+ supported. Use `~.Axes.pcolor` if you need this functionality.
5969
+
5970
+ .. _axes-pcolormesh-grid-orientation:
5971
+
5972
+ **Grid orientation**
5973
+
5974
+ The grid orientation follows the standard matrix convention: An array
5975
+ *C* with shape (nrows, ncolumns) is plotted with the column number as
5976
+ *X* and the row number as *Y*.
5977
+
5978
+ .. _differences-pcolor-pcolormesh:
5979
+
5980
+ **Differences between pcolor() and pcolormesh()**
5981
+
5982
+ Both methods are used to create a pseudocolor plot of a 2-D array
5983
+ using quadrilaterals.
5984
+
5985
+ The main difference lies in the created object and internal data
5986
+ handling:
5987
+ While `~.Axes.pcolor` returns a `.PolyCollection`, `~.Axes.pcolormesh`
5988
+ returns a `.QuadMesh`. The latter is more specialized for the given
5989
+ purpose and thus is faster. It should almost always be preferred.
5990
+
5991
+ There is also a slight difference in the handling of masked arrays.
5992
+ Both `~.Axes.pcolor` and `~.Axes.pcolormesh` support masked arrays
5993
+ for *C*. However, only `~.Axes.pcolor` supports masked arrays for *X*
5994
+ and *Y*. The reason lies in the internal handling of the masked values.
5995
+ `~.Axes.pcolor` leaves out the respective polygons from the
5996
+ PolyCollection. `~.Axes.pcolormesh` sets the facecolor of the masked
5997
+ elements to transparent. You can see the difference when using
5998
+ edgecolors. While all edges are drawn irrespective of masking in a
5999
+ QuadMesh, the edge between two adjacent masked quadrilaterals in
6000
+ `~.Axes.pcolor` is not drawn as the corresponding polygons do not
6001
+ exist in the PolyCollection.
6002
+
6003
+ Another difference is the support of Gouraud shading in
6004
+ `~.Axes.pcolormesh`, which is not available with `~.Axes.pcolor`.
6005
+
5922
6006
"""
5923
6007
if not self ._hold :
5924
6008
self .cla ()
0 commit comments