Matplotlib中一些函数变量的声明

本文详细介绍了matplotlib库中几个核心的绘图函数,包括plt.annotate用于添加注释,plt.Scatter用于绘制散点图,plt.text用于添加文本,plt.bar用于绘制柱状图,plt.imshow用于显示图像,以及plot_surface用于绘制3D表面图。每个函数的参数和用法都有清晰的解释,帮助理解如何在Python中创建各种复杂图形。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

目录

plt.annotate参数说明 

plt.Scatter参数说明

plt.text()参数说明

plt.bar()参数说明

plt.imshow()参数说明

plot_surface()参数说明

plt.subplot2grid()参数说明


plt.annotate参数说明 

Annotate the point *xy* with text *text*.

In the simplest form, the text is placed at *xy*.

Optionally, the text can be displayed in another position *xytext*.
An arrow pointing from the text to the annotated point *xy* can then
be added by defining *arrowprops*.

Parameters
----------
text : str
    The text of the annotation.

xy : (float, float)
    The point *(x, y)* to annotate. The coordinate system is determined
    by *xycoords*.

xytext : (float, float), default: *xy*
    The position *(x, y)* to place the text at. The coordinate system
    is determined by *textcoords*.

xycoords : str or `.Artist` or `.Transform` or callable or (float, float), default: 'data'

    The coordinate system that *xy* is given in. The following types
    of values are supported:

    - One of the following strings:

      ==================== ============================================
      Value                Description
      ==================== ============================================
      'figure points'      Points from the lower left of the figure
      'figure pixels'      Pixels from the lower left of the figure
      'figure fraction'    Fraction of figure from lower left
      'subfigure points'   Points from the lower left of the subfigure
      'subfigure pixels'   Pixels from the lower left of the subfigure
      'subfigure fraction' Fraction of subfigure from lower left
      'axes points'        Points from lower left corner of axes
      'axes pixels'        Pixels from lower left corner of axes
      'axes fraction'      Fraction of axes from lower left
      'data'               Use the coordinate system of the object
                           being annotated (default)
      'polar'              *(theta, r)* if not native 'data'
                           coordinates
      ==================== ============================================

      Note that 'subfigure pixels' and 'figure pixels' are the same
      for the parent figure, so users who want code that is usable in
      a subfigure can use 'subfigure pixels'.

    - An `.Artist`: *xy* is interpreted as a fraction of the artist's
      `~matplotlib.transforms.Bbox`. E.g. *(0, 0)* would be the lower
      left corner of the bounding box and *(0.5, 1)* would be the
      center top of the bounding box.

    - A `.Transform` to transform *xy* to screen coordinates.

    - A function with one of the following signatures::

        def transform(renderer) -> Bbox
        def transform(renderer) -> Transform

      where *renderer* is a `.RendererBase` subclass.

      The result of the function is interpreted like the `.Artist` and
      `.Transform` cases above.

    - A tuple *(xcoords, ycoords)* specifying separate coordinate
      systems for *x* and *y*. *xcoords* and *ycoords* must each be
      of one of the above described types.

    See :ref:`plotting-guide-annotation` for more details.

textcoords : str or `.Artist` or `.Transform` or callable or (float, float), default: value of *xycoords*
    The coordinate system that *xytext* is given in.

    All *xycoords* values are valid as well as the following
    strings:

    =================   =========================================
    Value               Description
    =================   =========================================
    'offset points'     Offset (in points) from the *xy* value
    'offset pixels'     Offset (in pixels) from the *xy* value
    =================   =========================================

arrowprops : dict, optional
    The properties used to draw a `.FancyArrowPatch` arrow between the
    positions *xy* and *xytext*. Note that the edge of the arrow
    pointing to *xytext* will be centered on the text itself and may
    not point directly to the coordinates given in *xytext*.

    If *arrowprops* does not contain the key 'arrowstyle' the
    allowed keys are:

    ==========   ======================================================
    Key          Description
    ==========   ======================================================
    width        The width of the arrow in points
    headwidth    The width of the base of the arrow head in points
    headlength   The length of the arrow head in points
    shrink       Fraction of total length to shrink from both ends
    ?            Any key to :class:`matplotlib.patches.FancyArrowPatch`
    ==========   ======================================================

    If *arrowprops* contains the key 'arrowstyle' the
    above keys are forbidden.  The allowed values of
    ``'arrowstyle'`` are:

    ============   =============================================
    Name           Attrs
    ============   =============================================
    ``'-'``        None
    ``'->'``       head_length=0.4,head_width=0.2
    ``'-['``       widthB=1.0,lengthB=0.2,angleB=None
    ``'|-|'``      widthA=1.0,widthB=1.0
    ``'-|>'``      head_length=0.4,head_width=0.2
    ``'<-'``       head_length=0.4,head_width=0.2
    ``'<->'``      head_length=0.4,head_width=0.2
    ``'<|-'``      head_length=0.4,head_width=0.2
    ``'<|-|>'``    head_length=0.4,head_width=0.2
    ``'fancy'``    head_length=0.4,head_width=0.4,tail_width=0.4
    ``'simple'``   head_length=0.5,head_width=0.5,tail_width=0.2
    ``'wedge'``    tail_width=0.3,shrink_factor=0.5
    ============   =============================================

    Valid keys for `~matplotlib.patches.FancyArrowPatch` are:

    ===============  ==================================================
    Key              Description
    ===============  ==================================================
    arrowstyle       the arrow style
    connectionstyle  the connection style
    relpos           default is (0.5, 0.5)
    patchA           default is bounding box of the text
    patchB           default is None
    shrinkA          default is 2 points
    shrinkB          default is 2 points
    mutation_scale   default is text size (in points)
    mutation_aspect  default is 1.
    ?                any key for :class:`matplotlib.patches.PathPatch`
    ===============  ==================================================

    Defaults to None, i.e. no arrow is drawn.

annotation_clip : bool or None, default: None
    Whether to draw the annotation when the annotation point *xy* is
    outside the axes area.

    - If *True*, the annotation will only be drawn when *xy* is
      within the axes.
    - If *False*, the annotation will always be drawn.
    - If *None*, the annotation will only be drawn when *xy* is
      within the axes and *xycoords* is 'data'.

**kwargs
    Additional kwargs are passed to `~matplotlib.text.Text`.

Returns
-------
`.Annotation`

See Also
--------
:ref:`plotting-guide-annotation`

plt.Scatter参数说明

plt.scatter(
    x,
    y,
    s=None,
    c=None,
    marker=None,
    cmap=None,
    norm=None,
    vmin=None,
    vmax=None,
    alpha=None,
    linewidths=None,
    *,
    edgecolors=None,
    plotnonfinite=False,
    data=None,
    **kwargs,
)
Docstring:
A scatter plot of *y* vs. *x* with varying marker size and/or color.

Parameters
----------
x, y : float or array-like, shape (n, )
    The data positions.

s : float or array-like, shape (n, ), optional
    The marker size in points**2.
    Default is ``rcParams['lines.markersize'] ** 2``.

c : array-like or list of colors or color, optional
    The marker colors. Possible values:

    - A scalar or sequence of n numbers to be mapped to colors using
      *cmap* and *norm*.
    - A 2D array in which the rows are RGB or RGBA.
    - A sequence of colors of length n.
    - A single color format string.

    Note that *c* should not be a single numeric RGB or RGBA sequence
    because that is indistinguishable from an array of values to be
    colormapped. If you want to specify the same RGB or RGBA value for
    all points, use a 2D array with a single row.  Otherwise, value-
    matching will have precedence in case of a size matching with *x*
    and *y*.

    If you wish to specify a single color for all points
    prefer the *color* keyword argument.

    Defaults to `None`. In that case the marker color is determined
    by the value of *color*, *facecolor* or *facecolors*. In case
    those are not specified or `None`, the marker color is determined
    by the next color of the ``Axes``' current "shape and fill" color
    cycle. This cycle defaults to :rc:`axes.prop_cycle`.

marker : `~.markers.MarkerStyle`, default: :rc:`scatter.marker`
    The marker style. *marker* can be either an instance of the class
    or the text shorthand for a particular marker.
    See :mod:`matplotlib.markers` for more information about marker
    styles.

cmap : str or `~matplotlib.colors.Colormap`, default: :rc:`image.cmap`
    A `.Colormap` instance or registered colormap name. *cmap* is only
    used if *c* is an array of floats.

norm : `~matplotlib.colors.Normalize`, default: None
    If *c* is an array of floats, *norm* is used to scale the color
    data, *c*, in the range 0 to 1, in order to map into the colormap
    *cmap*.
    If *None*, use the default `.colors.Normalize`.

vmin, vmax : float, default: None
    *vmin* and *vmax* are used in conjunction with the default norm to
    map the color array *c* to the colormap *cmap*. If None, the
    respective min and max of the color array is used.
    It is deprecated to use *vmin*/*vmax* when *norm* is given.

alpha : float, default: None
    The alpha blending value, between 0 (transparent) and 1 (opaque).

linewidths : float or array-like, default: :rc:`lines.linewidth`
    The linewidth of the marker edges. Note: The default *edgecolors*
    is 'face'. You may want to change this as well.

edgecolors : {'face', 'none', *None*} or color or sequence of color, default: :rc:`scatter.edgecolors`
    The edge color of the marker. Possible values:

    - 'face': The edge color will always be the same as the face color.
    - 'none': No patch boundary will be drawn.
    - A color or sequence of colors.

    For non-filled markers, *edgecolors* is ignored. Instead, the color
    is determined like with 'face', i.e. from *c*, *colors*, or
    *facecolors*.

plotnonfinite : bool, default: False
    Whether to plot points with nonfinite *c* (i.e. ``inf``, ``-inf``
    or ``nan``). If ``True`` the points are drawn with the *bad*
    colormap color (see `.Colormap.set_bad`).

Returns
-------
`~matplotlib.collections.PathCollection`

Other Parameters
----------------
**kwargs : `~matplotlib.collections.Collection` properties

See Also
--------
plot : To plot scatter plots when markers are identical in size and
    color.

Notes
-----
* The `.plot` function will be faster for scatterplots where markers
  don't vary in size or color.

* Any or all of *x*, *y*, *s*, and *c* may be masked arrays, in which
  case all masks will be combined and only unmasked points will be
  plotted.

* Fundamentally, scatter works with 1D arrays; *x*, *y*, *s*, and *c*
  may be input as N-D arrays, but within scatter they will be
  flattened. The exception is *c*, which will be flattened only if its
  size matches the size of *x* and *y*.

.. note::
    In addition to the above described arguments, this function can take
    a *data* keyword argument. If such a *data* argument is given,
    the following arguments can also be string ``s``, which is
    interpreted as ``data[s]`` (unless this raises an exception):
    *x*, *y*, *s*, *linewidths*, *edgecolors*, *c*, *facecolor*, *facecolors*, *color*.

    Objects passed as **data** must support item access (``data[s]``) and
    membership test (``s in data``).

plt.text()参数说明

Add text to the Axes.

Add the text *s* to the Axes at location *x*, *y* in data coordinates.

Parameters
----------
x, y : float
    The position to place the text. By default, this is in data
    coordinates. The coordinate system can be changed using the
    *transform* parameter.

s : str
    The text.

fontdict : dict, default: None
    A dictionary to override the default text properties. If fontdict
    is None, the defaults are determined by `.rcParams`.

Returns
-------
`.Text`
    The created `.Text` instance.

Other Parameters
----------------
**kwargs : `~matplotlib.text.Text` properties.
    Other miscellaneous text parameters.

    Properties:
    agg_filter: a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array
    alpha: scalar or None
    animated: bool
    backgroundcolor: color
    bbox: dict with properties for `.patches.FancyBboxPatch`
    clip_box: `.Bbox`
    clip_on: bool
    clip_path: Patch or (Path, Transform) or None
    color or c: color
    contains: unknown
    figure: `.Figure`
    fontfamily or family: {FONTNAME, 'serif', 'sans-serif', 'cursive', 'fantasy', 'monospace'}
    fontproperties or font or font_properties: `.font_manager.FontProperties` or `str` or `pathlib.Path`
    fontsize or size: float or {'xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large'}
    fontstretch or stretch: {a numeric value in range 0-1000, 'ultra-condensed', 'extra-condensed', 'condensed', 'semi-condensed', 'normal', 'semi-expanded', 'expanded', 'extra-expanded', 'ultra-expanded'}
    fontstyle or style: {'normal', 'italic', 'oblique'}
    fontvariant or variant: {'normal', 'small-caps'}
    fontweight or weight: {a numeric value in range 0-1000, 'ultralight', 'light', 'normal', 'regular', 'book', 'medium', 'roman', 'semibold', 'demibold', 'demi', 'bold', 'heavy', 'extra bold', 'black'}
    gid: str
    horizontalalignment or ha: {'center', 'right', 'left'}
    in_layout: bool
    label: object
    linespacing: float (multiple of font size)
    math_fontfamily: str
    multialignment or ma: {'left', 'right', 'center'}
    path_effects: `.AbstractPathEffect`
    picker: None or bool or float or callable
    position: (float, float)
    rasterized: bool
    rotation: float or {'vertical', 'horizontal'}
    rotation_mode: {None, 'default', 'anchor'}
    sketch_params: (scale: float, length: float, randomness: float)
    snap: bool or None
    text: object
    transform: `.Transform`
    transform_rotates_text: bool
    url: str
    usetex: bool or None
    verticalalignment or va: {'center', 'top', 'bottom', 'baseline', 'center_baseline'}
    visible: bool
    wrap: bool
    x: float
    y: float
    zorder: float

Examples
--------
Individual keyword arguments can be used to override any given
parameter::

    >>> text(x, y, s, fontsize=12)

The default transform specifies that text is in data coords,
alternatively, you can specify text in axis coords ((0, 0) is
lower-left and (1, 1) is upper-right).  The example below places
text in the center of the Axes::

    >>> text(0.5, 0.5, 'matplotlib', horizontalalignment='center',
    ...      verticalalignment='center', transform=ax.transAxes)

You can put a rectangular box around the text instance (e.g., to
set a background color) by using the keyword *bbox*.  *bbox* is
a dictionary of `~matplotlib.patches.Rectangle`
properties.  For example::

    >>> text(x, y, s, bbox=dict(facecolor='red', alpha=0.5))

plt.bar()参数说明

plt.bar(
    x,
    height,
    width=0.8,
    bottom=None,
    *,
    align='center',
    data=None,
    **kwargs,
)
Docstring:
Make a bar plot.

The bars are positioned at *x* with the given *align*\ment. Their
dimensions are given by *height* and *width*. The vertical baseline
is *bottom* (default 0).

Many parameters can take either a single value applying to all bars
or a sequence of values, one for each bar.

Parameters
----------
x : float or array-like
    The x coordinates of the bars. See also *align* for the
    alignment of the bars to the coordinates.

height : float or array-like
    The height(s) of the bars.

width : float or array-like, default: 0.8
    The width(s) of the bars.

bottom : float or array-like, default: 0
    The y coordinate(s) of the bars bases.

align : {'center', 'edge'}, default: 'center'
    Alignment of the bars to the *x* coordinates:

    - 'center': Center the base on the *x* positions.
    - 'edge': Align the left edges of the bars with the *x* positions.

    To align the bars on the right edge pass a negative *width* and
    ``align='edge'``.

Returns
-------
`.BarContainer`
    Container with all the bars and optionally errorbars.

Other Parameters
----------------
color : color or list of color, optional
    The colors of the bar faces.

edgecolor : color or list of color, optional
    The colors of the bar edges.

linewidth : float or array-like, optional
    Width of the bar edge(s). If 0, don't draw edges.

tick_label : str or list of str, optional
    The tick labels of the bars.
    Default: None (Use default numeric labels.)

xerr, yerr : float or array-like of shape(N,) or shape(2, N), optional
    If not *None*, add horizontal / vertical errorbars to the bar tips.
    The values are +/- sizes relative to the data:

    - scalar: symmetric +/- values for all bars
    - shape(N,): symmetric +/- values for each bar
    - shape(2, N): Separate - and + values for each bar. First row
      contains the lower errors, the second row contains the upper
      errors.
    - *None*: No errorbar. (Default)

    See :doc:`/gallery/statistics/errorbar_features`
    for an example on the usage of ``xerr`` and ``yerr``.

ecolor : color or list of color, default: 'black'
    The line color of the errorbars.

capsize : float, default: :rc:`errorbar.capsize`
   The length of the error bar caps in points.

error_kw : dict, optional
    Dictionary of kwargs to be passed to the `~.Axes.errorbar`
    method. Values of *ecolor* or *capsize* defined here take
    precedence over the independent kwargs.

log : bool, default: False
    If *True*, set the y-axis to be log scale.

**kwargs : `.Rectangle` properties

Properties:
    agg_filter: a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array
    alpha: scalar or None
    animated: bool
    antialiased or aa: unknown
    capstyle: `.CapStyle` or {'butt', 'projecting', 'round'}
    clip_box: `.Bbox`
    clip_on: bool
    clip_path: Patch or (Path, Transform) or None
    color: color
    contains: unknown
    edgecolor or ec: color or None or 'auto'
    facecolor or fc: color or None
    figure: `.Figure`
    fill: bool
    gid: str
    hatch: {'/', '\\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
    in_layout: bool
    joinstyle: `.JoinStyle` or {'miter', 'round', 'bevel'}
    label: object
    linestyle or ls: {'-', '--', '-.', ':', '', (offset, on-off-seq), ...}
    linewidth or lw: float or None
    path_effects: `.AbstractPathEffect`
    picker: None or bool or float or callable
    rasterized: bool
    sketch_params: (scale: float, length: float, randomness: float)
    snap: bool or None
    transform: `.Transform`
    url: str
    visible: bool
    zorder: float

See Also
--------
barh : Plot a horizontal bar plot.

Notes
-----
Stacked bars can be achieved by passing individual *bottom* values per
bar. See :doc:`/gallery/lines_bars_and_markers/bar_stacked`.

.. note::
    In addition to the above described arguments, this function can take
    a *data* keyword argument. If such a *data* argument is given,
    every other argument can also be string ``s``, which is
    interpreted as ``data[s]`` (unless this raises an exception).

    Objects passed as **data** must support item access (``data[s]``) and
    membership test (``s in data``).

plt.imshow()参数说明

plt.imshow(
    X,
    cmap=None,
    norm=None,
    aspect=None,
    interpolation=None,
    alpha=None,
    vmin=None,
    vmax=None,
    origin=None,
    extent=None,
    *,
    filternorm=True,
    filterrad=4.0,
    resample=None,
    url=None,
    data=None,
    **kwargs,
)
Docstring:
Display data as an image, i.e., on a 2D regular raster.

The input may either be actual RGB(A) data, or 2D scalar data, which
will be rendered as a pseudocolor image. For displaying a grayscale
image set up the colormapping using the parameters
``cmap='gray', vmin=0, vmax=255``.

The number of pixels used to render an image is set by the Axes size
and the *dpi* of the figure. This can lead to aliasing artifacts when
the image is resampled because the displayed image size will usually
not match the size of *X* (see
:doc:`/gallery/images_contours_and_fields/image_antialiasing`).
The resampling can be controlled via the *interpolation* parameter
and/or :rc:`image.interpolation`.

Parameters
----------
X : array-like or PIL image
    The image data. Supported array shapes are:

    - (M, N): an image 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 image.

    Out-of-range RGB(A) values are clipped.

cmap : str or `~matplotlib.colors.Colormap`, default: :rc:`image.cmap`
    The Colormap instance or registered colormap name used to map
    scalar data to colors. This parameter is ignored for RGB(A) data.

norm : `~matplotlib.colors.Normalize`, optional
    The `.Normalize` instance used to scale scalar data to the [0, 1]
    range before mapping to colors using *cmap*. By default, a linear
    scaling mapping the lowest value to 0 and the highest to 1 is used.
    This parameter is ignored for RGB(A) data.

aspect : {'equal', 'auto'} or float, default: :rc:`image.aspect`
    The aspect ratio of the Axes.  This parameter is particularly
    relevant for images since it determines whether data pixels are
    square.

    This parameter is a shortcut for explicitly calling
    `.Axes.set_aspect`. See there for further details.

    - 'equal': Ensures an aspect ratio of 1. Pixels will be square
      (unless pixel sizes are explicitly made non-square in data
      coordinates using *extent*).
    - 'auto': The Axes is kept fixed and the aspect is adjusted so
      that the data fit in the Axes. In general, this will result in
      non-square pixels.

interpolation : str, default: :rc:`image.interpolation`
    The interpolation method used.

    Supported values are 'none', 'antialiased', 'nearest', 'bilinear',
    'bicubic', 'spline16', 'spline36', 'hanning', 'hamming', 'hermite',
    'kaiser', 'quadric', 'catrom', 'gaussian', 'bessel', 'mitchell',
    'sinc', 'lanczos', 'blackman'.

    If *interpolation* is 'none', then no interpolation is performed
    on the Agg, ps, pdf and svg backends. Other backends will fall back
    to 'nearest'. Note that most SVG renderers perform interpolation at
    rendering and that the default interpolation method they implement
    may differ.

    If *interpolation* is the default 'antialiased', then 'nearest'
    interpolation is used if the image is upsampled by more than a
    factor of three (i.e. the number of display pixels is at least
    three times the size of the data array).  If the upsampling rate is
    smaller than 3, or the image is downsampled, then 'hanning'
    interpolation is used to act as an anti-aliasing filter, unless the
    image happens to be upsampled by exactly a factor of two or one.

    See
    :doc:`/gallery/images_contours_and_fields/interpolation_methods`
    for an overview of the supported interpolation methods, and
    :doc:`/gallery/images_contours_and_fields/image_antialiasing` for
    a discussion of image antialiasing.

    Some interpolation methods require an additional radius parameter,
    which can be set by *filterrad*. Additionally, the antigrain image
    resize filter is controlled by the parameter *filternorm*.

alpha : float or array-like, optional
    The alpha blending value, between 0 (transparent) and 1 (opaque).
    If *alpha* is an array, the alpha blending values are applied pixel
    by pixel, and *alpha* must have the same shape as *X*.

vmin, vmax : float, 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 deprecated to use *vmin*/*vmax* when *norm* is given.
    When using RGB(A) data, parameters *vmin*/*vmax* are ignored.

origin : {'upper', 'lower'}, default: :rc:`image.origin`
    Place the [0, 0] index of the array in the upper left or lower
    left corner of the Axes. The convention (the default) 'upper' is
    typically used for matrices and images.

    Note that the vertical axis points upward for 'lower'
    but downward for 'upper'.

    See the :doc:`/tutorials/intermediate/imshow_extent` tutorial for
    examples and a more detailed description.

extent : floats (left, right, bottom, top), optional
    The bounding box in data coordinates that the image will fill.
    The image is stretched individually along x and y to fill the box.

    The default extent is determined by the following conditions.
    Pixels have unit size in data coordinates. Their centers are on
    integer coordinates, and their center coordinates range from 0 to
    columns-1 horizontally and from 0 to rows-1 vertically.

    Note that the direction of the vertical axis and thus the default
    values for top and bottom depend on *origin*:

    - For ``origin == 'upper'`` the default is
      ``(-0.5, numcols-0.5, numrows-0.5, -0.5)``.
    - For ``origin == 'lower'`` the default is
      ``(-0.5, numcols-0.5, -0.5, numrows-0.5)``.

    See the :doc:`/tutorials/intermediate/imshow_extent` tutorial for
    examples and a more detailed description.

filternorm : bool, default: True
    A parameter for the antigrain image resize filter (see the
    antigrain documentation).  If *filternorm* is set, the filter
    normalizes integer values and corrects the rounding errors. It
    doesn't do anything with the source floating point values, it
    corrects only integers according to the rule of 1.0 which means
    that any sum of pixel weights must be equal to 1.0.  So, the
    filter function must produce a graph of the proper shape.

filterrad : float > 0, default: 4.0
    The filter radius for filters that have a radius parameter, i.e.
    when interpolation is one of: 'sinc', 'lanczos' or 'blackman'.

resample : bool, default: :rc:`image.resample`
    When *True*, use a full resampling method.  When *False*, only
    resample when the output image is larger than the input image.

url : str, optional
    Set the url of the created `.AxesImage`. See `.Artist.set_url`.

Returns
-------
`~matplotlib.image.AxesImage`

Other Parameters
----------------
**kwargs : `~matplotlib.artist.Artist` properties
    These parameters are passed on to the constructor of the
    `.AxesImage` artist.

See Also
--------
matshow : Plot a matrix or an array as an image.

Notes
-----
Unless *extent* is used, pixel centers will be located at integer
coordinates. In other words: the origin will coincide with the center
of pixel (0, 0).

There are two common representations for RGB images with an alpha
channel:

-   Straight (unassociated) alpha: R, G, and B channels represent the
    color of the pixel, disregarding its opacity.
-   Premultiplied (associated) alpha: R, G, and B channels represent
    the color of the pixel, adjusted for its opacity by multiplication.

`~matplotlib.pyplot.imshow` expects RGB images adopting the straight
(unassociated) alpha representation.

.. note::
    In addition to the above described arguments, this function can take
    a *data* keyword argument. If such a *data* argument is given,
    every other argument can also be string ``s``, which is
    interpreted as ``data[s]`` (unless this raises an exception).

    Objects passed as **data** must support item access (``data[s]``) and
    membership test (``s in data``).

plot_surface()参数说明

ax.plot_surface(
    X,
    Y,
    Z,
    *args,
    norm=None,
    vmin=None,
    vmax=None,
    lightsource=None,
    **kwargs,
)
Docstring:
Create a surface plot.

By default it will be colored in shades of a solid color, but it also
supports colormapping by supplying the *cmap* argument.

.. note::

   The *rcount* and *ccount* kwargs, which both default to 50,
   determine the maximum number of samples used in each direction.  If
   the input data is larger, it will be downsampled (by slicing) to
   these numbers of points.

.. note::

   To maximize rendering speed consider setting *rstride* and *cstride*
   to divisors of the number of rows minus 1 and columns minus 1
   respectively. For example, given 51 rows rstride can be any of the
   divisors of 50.

   Similarly, a setting of *rstride* and *cstride* equal to 1 (or
   *rcount* and *ccount* equal the number of rows and columns) can use
   the optimized path.

Parameters
----------
X, Y, Z : 2D arrays
    Data values.

rcount, ccount : int
    Maximum number of samples used in each direction.  If the input
    data is larger, it will be downsampled (by slicing) to these
    numbers of points.  Defaults to 50.

    .. versionadded:: 2.0

rstride, cstride : int
    Downsampling stride in each direction.  These arguments are
    mutually exclusive with *rcount* and *ccount*.  If only one of
    *rstride* or *cstride* is set, the other defaults to 10.

    'classic' mode uses a default of ``rstride = cstride = 10`` instead
    of the new default of ``rcount = ccount = 50``.

color : color-like
    Color of the surface patches.

cmap : Colormap
    Colormap of the surface patches.

facecolors : array-like of colors.
    Colors of each individual patch.

norm : Normalize
    Normalization for the colormap.

vmin, vmax : float
    Bounds for the normalization.

shade : bool, default: True
    Whether to shade the facecolors.  Shading is always disabled when
    *cmap* is specified.

lightsource : `~matplotlib.colors.LightSource`
    The lightsource to use when *shade* is True.

**kwargs
    Other arguments are forwarded to `.Poly3DCollection`.

plt.subplot2grid()参数说明

Create a subplot at a specific location inside a regular grid.

Parameters
----------
shape : (int, int)
    Number of rows and of columns of the grid in which to place axis.
loc : (int, int)
    Row number and column number of the axis location within the grid.
rowspan : int, default: 1
    Number of rows for the axis to span downwards.
colspan : int, default: 1
    Number of columns for the axis to span to the right.
fig : `.Figure`, optional
    Figure to place the subplot in. Defaults to the current figure.
**kwargs
    Additional keyword arguments are handed to `~.Figure.add_subplot`.

Returns
-------
`.axes.SubplotBase`, or another subclass of `~.axes.Axes`

    The axes of the subplot.  The returned axes base class depends on the
    projection used.  It is `~.axes.Axes` if rectilinear projection is used
    and `.projections.polar.PolarAxes` if polar projection is used.  The
    returned axes is then a subplot subclass of the base class.

Notes
-----
The following call ::

    ax = subplot2grid((nrows, ncols), (row, col), rowspan, colspan)

is identical to ::

    fig = gcf()
    gs = fig.add_gridspec(nrows, ncols)
    ax = fig.add_subplot(gs[row:row+rowspan, col:col+colspan])

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值