![]() |
满身肌肉的四季豆 · AWS CLI 中的配置和凭证文件设置 - ...· 1 周前 · |
![]() |
爱跑步的沙滩裤 · 4000元以上手机性价比排行榜:小米14系列 ...· 8 月前 · |
![]() |
才高八斗的啄木鸟 · 这5条(段)高铁是4大通道的组成部分,202 ...· 11 月前 · |
![]() |
坏坏的大海 · 《玄空命理3000问》第4期:照夫镜_女性· 1 年前 · |
![]() |
沉稳的茶壶 · 用visual ...· 1 年前 · |
mpl position transform axes |
https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.pcolormesh.html |
![]() |
英勇无比的红茶
2 月前 |
matplotlib.artist
matplotlib.axes
matplotlib.axis
matplotlib.backend_bases
matplotlib.backend_managers
matplotlib.backend_tools
matplotlib.backends
matplotlib.backends.backend_mixed
matplotlib.backends.backend_template
matplotlib.backends.backend_agg
matplotlib.backends.backend_cairo
matplotlib.backends.backend_gtk3agg
,
matplotlib.backends.backend_gtk3cairo
matplotlib.backends.backend_gtk4agg
,
matplotlib.backends.backend_gtk4cairo
matplotlib.backends.backend_nbagg
matplotlib.backends.backend_pdf
matplotlib.backends.backend_pgf
matplotlib.backends.backend_ps
matplotlib.backends.registry
matplotlib.backends.backend_qtagg
,
matplotlib.backends.backend_qtcairo
matplotlib.backends.backend_svg
matplotlib.backends.backend_tkagg
,
matplotlib.backends.backend_tkcairo
matplotlib.backends.backend_webagg_core
matplotlib.backends.backend_webagg
matplotlib.backends.backend_wxagg
,
matplotlib.backends.backend_wxcairo
matplotlib.bezier
matplotlib.category
matplotlib.cbook
matplotlib.cm
matplotlib.collections
matplotlib.colorbar
matplotlib.colorizer
matplotlib.colors
matplotlib.container
matplotlib.contour
matplotlib.dates
matplotlib.dviread
matplotlib.figure
matplotlib.font_manager
matplotlib.ft2font
matplotlib.gridspec
matplotlib.hatch
matplotlib.image
matplotlib.inset
matplotlib.layout_engine
matplotlib.legend
matplotlib.legend_handler
matplotlib.lines
matplotlib.markers
matplotlib.mathtext
matplotlib.mlab
matplotlib.offsetbox
matplotlib.patches
matplotlib.path
matplotlib.patheffects
matplotlib.pyplot
matplotlib.projections
matplotlib.projections.polar
matplotlib.projections.geo
matplotlib.quiver
matplotlib.rcsetup
matplotlib.sankey
matplotlib.scale
matplotlib.sphinxext.mathmpl
matplotlib.sphinxext.plot_directive
matplotlib.sphinxext.figmpl_directive
matplotlib.sphinxext.roles
matplotlib.spines
matplotlib.style
matplotlib.table
matplotlib.testing
matplotlib.text
matplotlib.texmanager
matplotlib.ticker
matplotlib.transforms
matplotlib.tri
matplotlib.typing
matplotlib.units
matplotlib.widgets
matplotlib._afm
matplotlib._api
matplotlib._docstring
matplotlib._enums
matplotlib._type1font
matplotlib._tight_bbox
matplotlib._tight_layout
mpl_toolkits.mplot3d
mpl_toolkits.axes_grid1
mpl_toolkits.axisartist
pylab
Create a pseudocolor plot with a non-regular rectangular grid.
Call signature:
pcolormesh([X, Y,] C, /, **kwargs)
X and Y can be used to specify the corners of the quadrilaterals.
The arguments X, Y, C are positional-only.
pcolormesh
is similar to pcolor
. It is much faster
and preferred in most cases. For a detailed discussion on the
differences see Differences between pcolor() and pcolormesh().
- Parameters:
- Carray-like
The mesh data. Supported array shapes are:
(M, N) or M*N: a mesh with scalar data. The values are mapped to
colors using normalization and a colormap. See parameters norm,
cmap, vmin, vmax.
(M, N, 3): an image with RGB values (0-1 float or 0-255 int).
(M, N, 4): an image with RGBA values (0-1 float or 0-255 int),
i.e. including transparency.
The first two dimensions (M, N) define the rows and columns of
the mesh data.
- X, Yarray-like, optional
The coordinates of the corners of quadrilaterals of a pcolormesh:
(X[i+1, j], Y[i+1, j]) (X[i+1, j+1], Y[i+1, j+1])
●╶───╴●
│ │
●╶───╴●
(X[i, j], Y[i, j]) (X[i, j+1], Y[i, j+1])
Note that the column index corresponds to the x-coordinate, and
the row index corresponds to y. For details, see the
Notes section below.
If shading='flat'
the dimensions of X and Y should be one
greater than those of C, and the quadrilateral is colored due
to the value at C[i, j]
. If X, Y and C have equal
dimensions, a warning will be raised and the last row and column
of C will be ignored.
If shading='nearest'
or 'gouraud'
, the dimensions of X
and Y should be the same as those of C (if not, a ValueError
will be raised). For 'nearest'
the color C[i, j]
is
centered on (X[i, j], Y[i, j])
. For 'gouraud'
, a smooth
interpolation is carried out between the quadrilateral corners.
If X and/or Y are 1-D arrays or column vectors they will be
expanded as needed into the appropriate 2D arrays, making a
rectangular grid.
- cmapstr or
Colormap
, default: rcParams["image.cmap"]
(default: 'viridis'
) The Colormap instance or registered colormap name used to map scalar data
to colors.
- normstr or
Normalize
, optional The normalization method used to scale scalar data to the [0, 1] range
before mapping to colors using cmap. By default, a linear scaling is
used, mapping the lowest value to 0 and the highest to 1.
If given, this can be one of the following:
An instance of Normalize
or one of its subclasses
(see Colormap normalization).
A scale name, i.e. one of "linear", "log", "symlog", "logit", etc. For a
list of available scales, call matplotlib.scale.get_scale_names()
.
In that case, a suitable Normalize
subclass is dynamically generated
and instantiated.
- vmin, vmaxfloat, optional
When using scalar data and no explicit norm, vmin and vmax define
the data range that the colormap covers. By default, the colormap covers
the complete value range of the supplied data. It is an error to use
vmin/vmax when a norm instance is given (but using a str
norm
name together with vmin/vmax is acceptable).
- colorizer
Colorizer
or None, default: None The Colorizer object used to map color to data. If None, a Colorizer
object is created from a norm and cmap.
- edgecolors{'none', None, 'face', color, color sequence}, optional
The color of the edges. Defaults to 'none'. Possible values:
'none' or '': No edge.
None: rcParams["patch.edgecolor"]
(default: 'black'
) will be used. Note that currently
rcParams["patch.force_edgecolor"]
(default: False
) has to be True for this to work.
'face': Use the adjacent face color.
A color or sequence of colors will set the edge color.
The singular form edgecolor works as an alias.
- alphafloat, default: None
The alpha blending value, between 0 (transparent) and 1 (opaque).
- shading{'flat', 'nearest', 'gouraud', 'auto'}, optional
The fill style for the quadrilateral; defaults to
rcParams["pcolor.shading"]
(default: 'auto'
). Possible values:
'flat': A solid color is used for each quad. The color of the
quad (i, j), (i+1, j), (i, j+1), (i+1, j+1) is given by
C[i, j]
. The dimensions of X and Y should be
one greater than those of C; if they are the same as C,
then a deprecation warning is raised, and the last row
and column of C are dropped.
'nearest': Each grid point will have a color centered on it,
extending halfway between the adjacent grid centers. The
dimensions of X and Y must be the same as C.
'gouraud': Each quad will be Gouraud shaded: The color of the
corners (i', j') are given by C[i', j']
. The color values of
the area in between is interpolated from the corner values.
The dimensions of X and Y must be the same as C. When
Gouraud shading is used, edgecolors is ignored.
'auto': Choose 'flat' if dimensions of X and Y are one
larger than C. Choose 'nearest' if dimensions are the same.
See pcolormesh grids and shading
for more description.
- snapbool, default: False
Whether to snap the mesh to pixel boundaries.
- rasterizedbool, optional
Rasterize the pcolormesh when drawing vector graphics. This can
speed up rendering and produce smaller files for large data sets.
See also Rasterization for vector graphics.
- Returns:
matplotlib.collections.QuadMesh
-
- Other Parameters:
- dataindexable object, optional
If given, all parameters also accept a string s
, which is
interpreted as data[s]
if s
is a key in data
.
- **kwargs
Additionally, the following arguments are allowed. They are passed
along to the QuadMesh
constructor:
Property
Description
a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array and two offsets from the bottom left corner of the image
array-like or float or None
antialiased
or aa
or antialiaseds
bool or list of bools
array
array-like
CapStyle
or {'butt', 'projecting', 'round'}
(vmin: float, vmax: float)
BboxBase
or None
Patch or (Path, Transform) or None
Colormap
or str or None
color or list of RGBA tuples
edgecolor
or ec
or edgecolors
color or list of color or 'face'
facecolor
or facecolors
or fc
{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
unknown
JoinStyle
or {'miter', 'round', 'bevel'}
object
linestyle
or dashes
or linestyles
or ls
str or tuple or list thereof
linewidth
or linewidths
or lw
float or list of floats
Normalize
or str or None
offset_transform
or transOffset
(N, 2) or (2,) array-like
list of AbstractPathEffect
None or bool or float or callable
float
(scale: float, length: float, randomness: float)
bool or None
list of str or None
float
See also
pcolor
An alternative implementation with slightly different features. For a detailed discussion on the differences see Differences between pcolor() and pcolormesh().
imshow
If X and Y are each equidistant, imshow
can be a faster alternative.
Notes
This is the pyplot wrapper for axes.Axes.pcolormesh
.
Masked arrays
C may be a masked array. If C[i, j]
is masked, the corresponding
quadrilateral will be transparent. Masking of X and Y is not
supported. Use pcolor
if you need this functionality.
Grid orientation
The grid orientation follows the standard matrix convention: An array
C with shape (nrows, ncolumns) is plotted with the column number as
X and the row number as Y.
Differences between pcolor() and pcolormesh()
Both methods are used to create a pseudocolor plot of a 2D array
using quadrilaterals.
The main difference lies in the created object and internal data
handling:
While pcolor
returns a PolyQuadMesh
, pcolormesh
returns a QuadMesh
. The latter is more specialized for the given
purpose and thus is faster. It should almost always be preferred.
There is also a slight difference in the handling of masked arrays.
Both pcolor
and pcolormesh
support masked arrays
for C. However, only pcolor
supports masked arrays for X
and Y. The reason lies in the internal handling of the masked values.
pcolor
leaves out the respective polygons from the
PolyQuadMesh. pcolormesh
sets the facecolor of the masked
elements to transparent. You can see the difference when using
edgecolors. While all edges are drawn irrespective of masking in a
QuadMesh, the edge between two adjacent masked quadrilaterals in
pcolor
is not drawn as the corresponding polygons do not
exist in the PolyQuadMesh. Because PolyQuadMesh draws each individual
polygon, it also supports applying hatches and linestyles to the collection.
Another difference is the support of Gouraud shading in
pcolormesh
, which is not available with pcolor
.
Examples using matplotlib.pyplot.pcolormesh
#
pcolor images
pcolormesh grids and shading
pcolormesh
QuadMesh Demo
Rasterization for vector graphics
Rasterization for vector graphics
Time Series Histogram
![]() |
坏坏的大海 · 《玄空命理3000问》第4期:照夫镜_女性 1 年前 |