You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2053 lines
79 KiB
2053 lines
79 KiB
"""
|
|
This type stub file was generated by pyright.
|
|
"""
|
|
|
|
import matplotlib
|
|
import matplotlib.image
|
|
import numpy as np
|
|
import datetime
|
|
import pathlib
|
|
import os
|
|
import PIL.Image
|
|
from contextlib import AbstractContextManager, ExitStack
|
|
from typing import Any, BinaryIO, Literal, TYPE_CHECKING, TypeVar, overload
|
|
from matplotlib import _api, _docstring, cbook, rcParams as rcParams, rcsetup
|
|
from matplotlib.backend_bases import Event, FigureCanvasBase, FigureManagerBase, MouseButton, RendererBase
|
|
from matplotlib.figure import Figure, SubFigure
|
|
from matplotlib.artist import Artist
|
|
from matplotlib.axes import Axes
|
|
from matplotlib.scale import ScaleBase
|
|
from matplotlib.cm import ScalarMappable
|
|
from matplotlib.colors import Colormap, Normalize
|
|
from collections.abc import Callable, Hashable, Iterable, Sequence
|
|
from typing_extensions import ParamSpec
|
|
from numpy.typing import ArrayLike
|
|
from matplotlib.axis import Tick
|
|
from matplotlib.axes._base import _AxesBase
|
|
from matplotlib.contour import ContourSet, QuadContourSet
|
|
from matplotlib.collections import BrokenBarHCollection, Collection, EventCollection, LineCollection, PathCollection, PolyCollection, QuadMesh
|
|
from matplotlib.colorbar import Colorbar
|
|
from matplotlib.container import BarContainer, ErrorbarContainer, StemContainer
|
|
from matplotlib.legend import Legend
|
|
from matplotlib.mlab import GaussianKDE
|
|
from matplotlib.image import AxesImage, FigureImage
|
|
from matplotlib.patches import FancyArrow, Polygon, StepPatch, Wedge
|
|
from matplotlib.quiver import Barbs, Quiver, QuiverKey
|
|
from matplotlib.transforms import Bbox, Transform
|
|
from matplotlib.typing import ColorType, HashableList, LineStyleType, MarkerType
|
|
from matplotlib.widgets import SubplotTool
|
|
from matplotlib.lines import Line2D
|
|
from matplotlib.text import Annotation, Text
|
|
|
|
"""
|
|
`matplotlib.pyplot` is a state-based interface to matplotlib. It provides
|
|
an implicit, MATLAB-like, way of plotting. It also opens figures on your
|
|
screen, and acts as the figure GUI manager.
|
|
|
|
pyplot is mainly intended for interactive plots and simple cases of
|
|
programmatic plot generation::
|
|
|
|
import numpy as np
|
|
import matplotlib.pyplot as plt
|
|
|
|
x = np.arange(0, 5, 0.1)
|
|
y = np.sin(x)
|
|
plt.plot(x, y)
|
|
|
|
The explicit object-oriented API is recommended for complex plots, though
|
|
pyplot is still usually used to create the figure and often the axes in the
|
|
figure. See `.pyplot.figure`, `.pyplot.subplots`, and
|
|
`.pyplot.subplot_mosaic` to create figures, and
|
|
:doc:`Axes API </api/axes_api>` for the plotting methods on an Axes::
|
|
|
|
import numpy as np
|
|
import matplotlib.pyplot as plt
|
|
|
|
x = np.arange(0, 5, 0.1)
|
|
y = np.sin(x)
|
|
fig, ax = plt.subplots()
|
|
ax.plot(x, y)
|
|
|
|
|
|
See :ref:`api_interfaces` for an explanation of the tradeoffs between the
|
|
implicit and explicit interfaces.
|
|
"""
|
|
if TYPE_CHECKING:
|
|
_P = ParamSpec('_P')
|
|
_R = TypeVar('_R')
|
|
_T = TypeVar('_T')
|
|
_log = ...
|
|
colormaps = ...
|
|
color_sequences = ...
|
|
_ReplDisplayHook = ...
|
|
_REPL_DISPLAYHOOK = ...
|
|
def install_repl_displayhook() -> None:
|
|
"""
|
|
Connect to the display hook of the current shell.
|
|
|
|
The display hook gets called when the read-evaluate-print-loop (REPL) of
|
|
the shell has finished the execution of a command. We use this callback
|
|
to be able to automatically update a figure in interactive mode.
|
|
|
|
This works both with IPython and with vanilla python shells.
|
|
"""
|
|
...
|
|
|
|
def uninstall_repl_displayhook() -> None:
|
|
"""Disconnect from the display hook of the current shell."""
|
|
...
|
|
|
|
draw_all = ...
|
|
@_copy_docstring_and_deprecators(matplotlib.set_loglevel)
|
|
def set_loglevel(*args, **kwargs) -> None:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Artist.findobj)
|
|
def findobj(o: Artist | None = ..., match: Callable[[Artist], bool] | type[Artist] | None = ..., include_self: bool = ...) -> list[Artist]:
|
|
...
|
|
|
|
_backend_mod: type[matplotlib.backend_bases._Backend] | None = ...
|
|
def switch_backend(newbackend: str) -> None:
|
|
"""
|
|
Set the pyplot backend.
|
|
|
|
Switching to an interactive backend is possible only if no event loop for
|
|
another interactive backend has started. Switching to and from
|
|
non-interactive backends is always possible.
|
|
|
|
If the new backend is different than the current backend then all open
|
|
Figures will be closed via ``plt.close('all')``.
|
|
|
|
Parameters
|
|
----------
|
|
newbackend : str
|
|
The case-insensitive name of the backend to use.
|
|
|
|
"""
|
|
class backend_mod(matplotlib.backend_bases._Backend):
|
|
...
|
|
|
|
|
|
|
|
def new_figure_manager(*args, **kwargs):
|
|
"""Create a new figure manager instance."""
|
|
...
|
|
|
|
def draw_if_interactive(*args, **kwargs):
|
|
"""
|
|
Redraw the current figure if in interactive mode.
|
|
|
|
.. warning::
|
|
|
|
End users will typically not have to call this function because the
|
|
the interactive mode takes care of this.
|
|
"""
|
|
...
|
|
|
|
def show(*args, **kwargs):
|
|
"""
|
|
Display all open figures.
|
|
|
|
Parameters
|
|
----------
|
|
block : bool, optional
|
|
Whether to wait for all figures to be closed before returning.
|
|
|
|
If `True` block and run the GUI main loop until all figure windows
|
|
are closed.
|
|
|
|
If `False` ensure that all figure windows are displayed and return
|
|
immediately. In this case, you are responsible for ensuring
|
|
that the event loop is running to have responsive figures.
|
|
|
|
Defaults to True in non-interactive mode and to False in interactive
|
|
mode (see `.pyplot.isinteractive`).
|
|
|
|
See Also
|
|
--------
|
|
ion : Enable interactive mode, which shows / updates the figure after
|
|
every plotting command, so that calling ``show()`` is not necessary.
|
|
ioff : Disable interactive mode.
|
|
savefig : Save the figure to an image file instead of showing it on screen.
|
|
|
|
Notes
|
|
-----
|
|
**Saving figures to file and showing a window at the same time**
|
|
|
|
If you want an image file as well as a user interface window, use
|
|
`.pyplot.savefig` before `.pyplot.show`. At the end of (a blocking)
|
|
``show()`` the figure is closed and thus unregistered from pyplot. Calling
|
|
`.pyplot.savefig` afterwards would save a new and thus empty figure. This
|
|
limitation of command order does not apply if the show is non-blocking or
|
|
if you keep a reference to the figure and use `.Figure.savefig`.
|
|
|
|
**Auto-show in jupyter notebooks**
|
|
|
|
The jupyter backends (activated via ``%matplotlib inline``,
|
|
``%matplotlib notebook``, or ``%matplotlib widget``), call ``show()`` at
|
|
the end of every cell by default. Thus, you usually don't have to call it
|
|
explicitly there.
|
|
"""
|
|
...
|
|
|
|
def isinteractive() -> bool:
|
|
"""
|
|
Return whether plots are updated after every plotting command.
|
|
|
|
The interactive mode is mainly useful if you build plots from the command
|
|
line and want to see the effect of each command while you are building the
|
|
figure.
|
|
|
|
In interactive mode:
|
|
|
|
- newly created figures will be shown immediately;
|
|
- figures will automatically redraw on change;
|
|
- `.pyplot.show` will not block by default.
|
|
|
|
In non-interactive mode:
|
|
|
|
- newly created figures and changes to figures will not be reflected until
|
|
explicitly asked to be;
|
|
- `.pyplot.show` will block by default.
|
|
|
|
See Also
|
|
--------
|
|
ion : Enable interactive mode.
|
|
ioff : Disable interactive mode.
|
|
show : Show all figures (and maybe block).
|
|
pause : Show all figures, and block for a time.
|
|
"""
|
|
...
|
|
|
|
def ioff() -> ExitStack:
|
|
"""
|
|
Disable interactive mode.
|
|
|
|
See `.pyplot.isinteractive` for more details.
|
|
|
|
See Also
|
|
--------
|
|
ion : Enable interactive mode.
|
|
isinteractive : Whether interactive mode is enabled.
|
|
show : Show all figures (and maybe block).
|
|
pause : Show all figures, and block for a time.
|
|
|
|
Notes
|
|
-----
|
|
For a temporary change, this can be used as a context manager::
|
|
|
|
# if interactive mode is on
|
|
# then figures will be shown on creation
|
|
plt.ion()
|
|
# This figure will be shown immediately
|
|
fig = plt.figure()
|
|
|
|
with plt.ioff():
|
|
# interactive mode will be off
|
|
# figures will not automatically be shown
|
|
fig2 = plt.figure()
|
|
# ...
|
|
|
|
To enable optional usage as a context manager, this function returns a
|
|
`~contextlib.ExitStack` object, which is not intended to be stored or
|
|
accessed by the user.
|
|
"""
|
|
...
|
|
|
|
def ion() -> ExitStack:
|
|
"""
|
|
Enable interactive mode.
|
|
|
|
See `.pyplot.isinteractive` for more details.
|
|
|
|
See Also
|
|
--------
|
|
ioff : Disable interactive mode.
|
|
isinteractive : Whether interactive mode is enabled.
|
|
show : Show all figures (and maybe block).
|
|
pause : Show all figures, and block for a time.
|
|
|
|
Notes
|
|
-----
|
|
For a temporary change, this can be used as a context manager::
|
|
|
|
# if interactive mode is off
|
|
# then figures will not be shown on creation
|
|
plt.ioff()
|
|
# This figure will not be shown immediately
|
|
fig = plt.figure()
|
|
|
|
with plt.ion():
|
|
# interactive mode will be on
|
|
# figures will automatically be shown
|
|
fig2 = plt.figure()
|
|
# ...
|
|
|
|
To enable optional usage as a context manager, this function returns a
|
|
`~contextlib.ExitStack` object, which is not intended to be stored or
|
|
accessed by the user.
|
|
"""
|
|
...
|
|
|
|
def pause(interval: float) -> None:
|
|
"""
|
|
Run the GUI event loop for *interval* seconds.
|
|
|
|
If there is an active figure, it will be updated and displayed before the
|
|
pause, and the GUI event loop (if any) will run during the pause.
|
|
|
|
This can be used for crude animation. For more complex animation use
|
|
:mod:`matplotlib.animation`.
|
|
|
|
If there is no active figure, sleep for *interval* seconds instead.
|
|
|
|
See Also
|
|
--------
|
|
matplotlib.animation : Proper animations
|
|
show : Show all figures and optional block until all figures are closed.
|
|
"""
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(matplotlib.rc)
|
|
def rc(group: str, **kwargs) -> None:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(matplotlib.rc_context)
|
|
def rc_context(rc: dict[str, Any] | None = ..., fname: str | pathlib.Path | os.PathLike | None = ...) -> AbstractContextManager[None]:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(matplotlib.rcdefaults)
|
|
def rcdefaults() -> None:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(matplotlib.artist.getp)
|
|
def getp(obj, *args, **kwargs):
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(matplotlib.artist.get)
|
|
def get(obj, *args, **kwargs):
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(matplotlib.artist.setp)
|
|
def setp(obj, *args, **kwargs):
|
|
...
|
|
|
|
def xkcd(scale: float = ..., length: float = ..., randomness: float = ...) -> ExitStack:
|
|
"""
|
|
Turn on `xkcd <https://xkcd.com/>`_ sketch-style drawing mode. This will
|
|
only have effect on things drawn after this function is called.
|
|
|
|
For best results, the "Humor Sans" font should be installed: it is
|
|
not included with Matplotlib.
|
|
|
|
Parameters
|
|
----------
|
|
scale : float, optional
|
|
The amplitude of the wiggle perpendicular to the source line.
|
|
length : float, optional
|
|
The length of the wiggle along the line.
|
|
randomness : float, optional
|
|
The scale factor by which the length is shrunken or expanded.
|
|
|
|
Notes
|
|
-----
|
|
This function works by a number of rcParams, so it will probably
|
|
override others you have set before.
|
|
|
|
If you want the effects of this function to be temporary, it can
|
|
be used as a context manager, for example::
|
|
|
|
with plt.xkcd():
|
|
# This figure will be in XKCD-style
|
|
fig1 = plt.figure()
|
|
# ...
|
|
|
|
# This figure will be in regular style
|
|
fig2 = plt.figure()
|
|
"""
|
|
...
|
|
|
|
def figure(num: int | str | Figure | SubFigure | None = ..., figsize: tuple[float, float] | None = ..., dpi: float | None = ..., *, facecolor: ColorType | None = ..., edgecolor: ColorType | None = ..., frameon: bool = ..., FigureClass: type[Figure] = ..., clear: bool = ..., **kwargs) -> Figure:
|
|
"""
|
|
Create a new figure, or activate an existing figure.
|
|
|
|
Parameters
|
|
----------
|
|
num : int or str or `.Figure` or `.SubFigure`, optional
|
|
A unique identifier for the figure.
|
|
|
|
If a figure with that identifier already exists, this figure is made
|
|
active and returned. An integer refers to the ``Figure.number``
|
|
attribute, a string refers to the figure label.
|
|
|
|
If there is no figure with the identifier or *num* is not given, a new
|
|
figure is created, made active and returned. If *num* is an int, it
|
|
will be used for the ``Figure.number`` attribute, otherwise, an
|
|
auto-generated integer value is used (starting at 1 and incremented
|
|
for each new figure). If *num* is a string, the figure label and the
|
|
window title is set to this value. If num is a ``SubFigure``, its
|
|
parent ``Figure`` is activated.
|
|
|
|
figsize : (float, float), default: :rc:`figure.figsize`
|
|
Width, height in inches.
|
|
|
|
dpi : float, default: :rc:`figure.dpi`
|
|
The resolution of the figure in dots-per-inch.
|
|
|
|
facecolor : color, default: :rc:`figure.facecolor`
|
|
The background color.
|
|
|
|
edgecolor : color, default: :rc:`figure.edgecolor`
|
|
The border color.
|
|
|
|
frameon : bool, default: True
|
|
If False, suppress drawing the figure frame.
|
|
|
|
FigureClass : subclass of `~matplotlib.figure.Figure`
|
|
If set, an instance of this subclass will be created, rather than a
|
|
plain `.Figure`.
|
|
|
|
clear : bool, default: False
|
|
If True and the figure already exists, then it is cleared.
|
|
|
|
layout : {'constrained', 'compressed', 'tight', 'none', `.LayoutEngine`, None}, \
|
|
default: None
|
|
The layout mechanism for positioning of plot elements to avoid
|
|
overlapping Axes decorations (labels, ticks, etc). Note that layout
|
|
managers can measurably slow down figure display.
|
|
|
|
- 'constrained': The constrained layout solver adjusts axes sizes
|
|
to avoid overlapping axes decorations. Can handle complex plot
|
|
layouts and colorbars, and is thus recommended.
|
|
|
|
See :ref:`constrainedlayout_guide`
|
|
for examples.
|
|
|
|
- 'compressed': uses the same algorithm as 'constrained', but
|
|
removes extra space between fixed-aspect-ratio Axes. Best for
|
|
simple grids of axes.
|
|
|
|
- 'tight': Use the tight layout mechanism. This is a relatively
|
|
simple algorithm that adjusts the subplot parameters so that
|
|
decorations do not overlap. See `.Figure.set_tight_layout` for
|
|
further details.
|
|
|
|
- 'none': Do not use a layout engine.
|
|
|
|
- A `.LayoutEngine` instance. Builtin layout classes are
|
|
`.ConstrainedLayoutEngine` and `.TightLayoutEngine`, more easily
|
|
accessible by 'constrained' and 'tight'. Passing an instance
|
|
allows third parties to provide their own layout engine.
|
|
|
|
If not given, fall back to using the parameters *tight_layout* and
|
|
*constrained_layout*, including their config defaults
|
|
:rc:`figure.autolayout` and :rc:`figure.constrained_layout.use`.
|
|
|
|
**kwargs
|
|
Additional keyword arguments are passed to the `.Figure` constructor.
|
|
|
|
Returns
|
|
-------
|
|
`~matplotlib.figure.Figure`
|
|
|
|
Notes
|
|
-----
|
|
A newly created figure is passed to the `~.FigureCanvasBase.new_manager`
|
|
method or the `new_figure_manager` function provided by the current
|
|
backend, which install a canvas and a manager on the figure.
|
|
|
|
Once this is done, :rc:`figure.hooks` are called, one at a time, on the
|
|
figure; these hooks allow arbitrary customization of the figure (e.g.,
|
|
attaching callbacks) or of associated elements (e.g., modifying the
|
|
toolbar). See :doc:`/gallery/user_interfaces/mplcvd` for an example of
|
|
toolbar customization.
|
|
|
|
If you are creating many figures, make sure you explicitly call
|
|
`.pyplot.close` on the figures you are not using, because this will
|
|
enable pyplot to properly clean up the memory.
|
|
|
|
`~matplotlib.rcParams` defines the default values, which can be modified
|
|
in the matplotlibrc file.
|
|
"""
|
|
...
|
|
|
|
def gcf() -> Figure:
|
|
"""
|
|
Get the current figure.
|
|
|
|
If there is currently no figure on the pyplot figure stack, a new one is
|
|
created using `~.pyplot.figure()`. (To test whether there is currently a
|
|
figure on the pyplot figure stack, check whether `~.pyplot.get_fignums()`
|
|
is empty.)
|
|
"""
|
|
...
|
|
|
|
def fignum_exists(num: int) -> bool:
|
|
"""Return whether the figure with the given id exists."""
|
|
...
|
|
|
|
def get_fignums() -> list[int]:
|
|
"""Return a list of existing figure numbers."""
|
|
...
|
|
|
|
def get_figlabels() -> list[Any]:
|
|
"""Return a list of existing figure labels."""
|
|
...
|
|
|
|
def get_current_fig_manager() -> FigureManagerBase | None:
|
|
"""
|
|
Return the figure manager of the current figure.
|
|
|
|
The figure manager is a container for the actual backend-depended window
|
|
that displays the figure on screen.
|
|
|
|
If no current figure exists, a new one is created, and its figure
|
|
manager is returned.
|
|
|
|
Returns
|
|
-------
|
|
`.FigureManagerBase` or backend-dependent subclass thereof
|
|
"""
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(FigureCanvasBase.mpl_connect)
|
|
def connect(s: str, func: Callable[[Event], Any]) -> int:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(FigureCanvasBase.mpl_disconnect)
|
|
def disconnect(cid: int) -> None:
|
|
...
|
|
|
|
def close(fig: None | int | str | Figure | Literal["all"] = ...) -> None:
|
|
"""
|
|
Close a figure window.
|
|
|
|
Parameters
|
|
----------
|
|
fig : None or int or str or `.Figure`
|
|
The figure to close. There are a number of ways to specify this:
|
|
|
|
- *None*: the current figure
|
|
- `.Figure`: the given `.Figure` instance
|
|
- ``int``: a figure number
|
|
- ``str``: a figure name
|
|
- 'all': all figures
|
|
|
|
"""
|
|
...
|
|
|
|
def clf() -> None:
|
|
"""Clear the current figure."""
|
|
...
|
|
|
|
def draw() -> None:
|
|
"""
|
|
Redraw the current figure.
|
|
|
|
This is used to update a figure that has been altered, but not
|
|
automatically re-drawn. If interactive mode is on (via `.ion()`), this
|
|
should be only rarely needed, but there may be ways to modify the state of
|
|
a figure without marking it as "stale". Please report these cases as bugs.
|
|
|
|
This is equivalent to calling ``fig.canvas.draw_idle()``, where ``fig`` is
|
|
the current figure.
|
|
|
|
See Also
|
|
--------
|
|
.FigureCanvasBase.draw_idle
|
|
.FigureCanvasBase.draw
|
|
"""
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Figure.savefig)
|
|
def savefig(*args, **kwargs) -> None:
|
|
...
|
|
|
|
def figlegend(*args, **kwargs) -> Legend:
|
|
...
|
|
|
|
if Figure.legend.__doc__:
|
|
...
|
|
@_docstring.dedent_interpd
|
|
def axes(arg: None | tuple[float, float, float, float] = ..., **kwargs) -> matplotlib.axes.Axes:
|
|
"""
|
|
Add an Axes to the current figure and make it the current Axes.
|
|
|
|
Call signatures::
|
|
|
|
plt.axes()
|
|
plt.axes(rect, projection=None, polar=False, **kwargs)
|
|
plt.axes(ax)
|
|
|
|
Parameters
|
|
----------
|
|
arg : None or 4-tuple
|
|
The exact behavior of this function depends on the type:
|
|
|
|
- *None*: A new full window Axes is added using
|
|
``subplot(**kwargs)``.
|
|
- 4-tuple of floats *rect* = ``(left, bottom, width, height)``.
|
|
A new Axes is added with dimensions *rect* in normalized
|
|
(0, 1) units using `~.Figure.add_axes` on the current figure.
|
|
|
|
projection : {None, 'aitoff', 'hammer', 'lambert', 'mollweide', \
|
|
'polar', 'rectilinear', str}, optional
|
|
The projection type of the `~.axes.Axes`. *str* is the name of
|
|
a custom projection, see `~matplotlib.projections`. The default
|
|
None results in a 'rectilinear' projection.
|
|
|
|
polar : bool, default: False
|
|
If True, equivalent to projection='polar'.
|
|
|
|
sharex, sharey : `~matplotlib.axes.Axes`, optional
|
|
Share the x or y `~matplotlib.axis` with sharex and/or sharey.
|
|
The axis will have the same limits, ticks, and scale as the axis
|
|
of the shared Axes.
|
|
|
|
label : str
|
|
A label for the returned Axes.
|
|
|
|
Returns
|
|
-------
|
|
`~.axes.Axes`, or a subclass of `~.axes.Axes`
|
|
The returned axes class depends on the projection used. It is
|
|
`~.axes.Axes` if rectilinear projection is used and
|
|
`.projections.polar.PolarAxes` if polar projection is used.
|
|
|
|
Other Parameters
|
|
----------------
|
|
**kwargs
|
|
This method also takes the keyword arguments for
|
|
the returned Axes class. The keyword arguments for the
|
|
rectilinear Axes class `~.axes.Axes` can be found in
|
|
the following table but there might also be other keyword
|
|
arguments if another projection is used, see the actual Axes
|
|
class.
|
|
|
|
%(Axes:kwdoc)s
|
|
|
|
See Also
|
|
--------
|
|
.Figure.add_axes
|
|
.pyplot.subplot
|
|
.Figure.add_subplot
|
|
.Figure.subplots
|
|
.pyplot.subplots
|
|
|
|
Examples
|
|
--------
|
|
::
|
|
|
|
# Creating a new full window Axes
|
|
plt.axes()
|
|
|
|
# Creating a new Axes with specified dimensions and a grey background
|
|
plt.axes((left, bottom, width, height), facecolor='grey')
|
|
"""
|
|
...
|
|
|
|
def delaxes(ax: matplotlib.axes.Axes | None = ...) -> None:
|
|
"""
|
|
Remove an `~.axes.Axes` (defaulting to the current axes) from its figure.
|
|
"""
|
|
...
|
|
|
|
def sca(ax: Axes) -> None:
|
|
"""
|
|
Set the current Axes to *ax* and the current Figure to the parent of *ax*.
|
|
"""
|
|
...
|
|
|
|
def cla() -> None:
|
|
"""Clear the current axes."""
|
|
...
|
|
|
|
@_docstring.dedent_interpd
|
|
def subplot(*args, **kwargs) -> Axes:
|
|
"""
|
|
Add an Axes to the current figure or retrieve an existing Axes.
|
|
|
|
This is a wrapper of `.Figure.add_subplot` which provides additional
|
|
behavior when working with the implicit API (see the notes section).
|
|
|
|
Call signatures::
|
|
|
|
subplot(nrows, ncols, index, **kwargs)
|
|
subplot(pos, **kwargs)
|
|
subplot(**kwargs)
|
|
subplot(ax)
|
|
|
|
Parameters
|
|
----------
|
|
*args : int, (int, int, *index*), or `.SubplotSpec`, default: (1, 1, 1)
|
|
The position of the subplot described by one of
|
|
|
|
- Three integers (*nrows*, *ncols*, *index*). The subplot will take the
|
|
*index* position on a grid with *nrows* rows and *ncols* columns.
|
|
*index* starts at 1 in the upper left corner and increases to the
|
|
right. *index* can also be a two-tuple specifying the (*first*,
|
|
*last*) indices (1-based, and including *last*) of the subplot, e.g.,
|
|
``fig.add_subplot(3, 1, (1, 2))`` makes a subplot that spans the
|
|
upper 2/3 of the figure.
|
|
- A 3-digit integer. The digits are interpreted as if given separately
|
|
as three single-digit integers, i.e. ``fig.add_subplot(235)`` is the
|
|
same as ``fig.add_subplot(2, 3, 5)``. Note that this can only be used
|
|
if there are no more than 9 subplots.
|
|
- A `.SubplotSpec`.
|
|
|
|
projection : {None, 'aitoff', 'hammer', 'lambert', 'mollweide', \
|
|
'polar', 'rectilinear', str}, optional
|
|
The projection type of the subplot (`~.axes.Axes`). *str* is the name
|
|
of a custom projection, see `~matplotlib.projections`. The default
|
|
None results in a 'rectilinear' projection.
|
|
|
|
polar : bool, default: False
|
|
If True, equivalent to projection='polar'.
|
|
|
|
sharex, sharey : `~matplotlib.axes.Axes`, optional
|
|
Share the x or y `~matplotlib.axis` with sharex and/or sharey. The
|
|
axis will have the same limits, ticks, and scale as the axis of the
|
|
shared axes.
|
|
|
|
label : str
|
|
A label for the returned axes.
|
|
|
|
Returns
|
|
-------
|
|
`~.axes.Axes`
|
|
|
|
The Axes of the subplot. The returned Axes can actually be an instance
|
|
of a subclass, such as `.projections.polar.PolarAxes` for polar
|
|
projections.
|
|
|
|
Other Parameters
|
|
----------------
|
|
**kwargs
|
|
This method also takes the keyword arguments for the returned axes
|
|
base class; except for the *figure* argument. The keyword arguments
|
|
for the rectilinear base class `~.axes.Axes` can be found in
|
|
the following table but there might also be other keyword
|
|
arguments if another projection is used.
|
|
|
|
%(Axes:kwdoc)s
|
|
|
|
Notes
|
|
-----
|
|
Creating a new Axes will delete any preexisting Axes that
|
|
overlaps with it beyond sharing a boundary::
|
|
|
|
import matplotlib.pyplot as plt
|
|
# plot a line, implicitly creating a subplot(111)
|
|
plt.plot([1, 2, 3])
|
|
# now create a subplot which represents the top plot of a grid
|
|
# with 2 rows and 1 column. Since this subplot will overlap the
|
|
# first, the plot (and its axes) previously created, will be removed
|
|
plt.subplot(211)
|
|
|
|
If you do not want this behavior, use the `.Figure.add_subplot` method
|
|
or the `.pyplot.axes` function instead.
|
|
|
|
If no *kwargs* are passed and there exists an Axes in the location
|
|
specified by *args* then that Axes will be returned rather than a new
|
|
Axes being created.
|
|
|
|
If *kwargs* are passed and there exists an Axes in the location
|
|
specified by *args*, the projection type is the same, and the
|
|
*kwargs* match with the existing Axes, then the existing Axes is
|
|
returned. Otherwise a new Axes is created with the specified
|
|
parameters. We save a reference to the *kwargs* which we use
|
|
for this comparison. If any of the values in *kwargs* are
|
|
mutable we will not detect the case where they are mutated.
|
|
In these cases we suggest using `.Figure.add_subplot` and the
|
|
explicit Axes API rather than the implicit pyplot API.
|
|
|
|
See Also
|
|
--------
|
|
.Figure.add_subplot
|
|
.pyplot.subplots
|
|
.pyplot.axes
|
|
.Figure.subplots
|
|
|
|
Examples
|
|
--------
|
|
::
|
|
|
|
plt.subplot(221)
|
|
|
|
# equivalent but more general
|
|
ax1 = plt.subplot(2, 2, 1)
|
|
|
|
# add a subplot with no frame
|
|
ax2 = plt.subplot(222, frameon=False)
|
|
|
|
# add a polar subplot
|
|
plt.subplot(223, projection='polar')
|
|
|
|
# add a red subplot that shares the x-axis with ax1
|
|
plt.subplot(224, sharex=ax1, facecolor='red')
|
|
|
|
# delete ax2 from the figure
|
|
plt.delaxes(ax2)
|
|
|
|
# add ax2 to the figure again
|
|
plt.subplot(ax2)
|
|
|
|
# make the first axes "current" again
|
|
plt.subplot(221)
|
|
|
|
"""
|
|
...
|
|
|
|
def subplots(nrows: int = ..., ncols: int = ..., *, sharex: bool | Literal["none", "all", "row", "col"] = ..., sharey: bool | Literal["none", "all", "row", "col"] = ..., squeeze: bool = ..., width_ratios: Sequence[float] | None = ..., height_ratios: Sequence[float] | None = ..., subplot_kw: dict[str, Any] | None = ..., gridspec_kw: dict[str, Any] | None = ..., **fig_kw) -> tuple[Figure, Any]:
|
|
"""
|
|
Create a figure and a set of subplots.
|
|
|
|
This utility wrapper makes it convenient to create common layouts of
|
|
subplots, including the enclosing figure object, in a single call.
|
|
|
|
Parameters
|
|
----------
|
|
nrows, ncols : int, default: 1
|
|
Number of rows/columns of the subplot grid.
|
|
|
|
sharex, sharey : bool or {'none', 'all', 'row', 'col'}, default: False
|
|
Controls sharing of properties among x (*sharex*) or y (*sharey*)
|
|
axes:
|
|
|
|
- True or 'all': x- or y-axis will be shared among all subplots.
|
|
- False or 'none': each subplot x- or y-axis will be independent.
|
|
- 'row': each subplot row will share an x- or y-axis.
|
|
- 'col': each subplot column will share an x- or y-axis.
|
|
|
|
When subplots have a shared x-axis along a column, only the x tick
|
|
labels of the bottom subplot are created. Similarly, when subplots
|
|
have a shared y-axis along a row, only the y tick labels of the first
|
|
column subplot are created. To later turn other subplots' ticklabels
|
|
on, use `~matplotlib.axes.Axes.tick_params`.
|
|
|
|
When subplots have a shared axis that has units, calling
|
|
`~matplotlib.axis.Axis.set_units` will update each axis with the
|
|
new units.
|
|
|
|
squeeze : bool, default: True
|
|
- If True, extra dimensions are squeezed out from the returned
|
|
array of `~matplotlib.axes.Axes`:
|
|
|
|
- if only one subplot is constructed (nrows=ncols=1), the
|
|
resulting single Axes object is returned as a scalar.
|
|
- for Nx1 or 1xM subplots, the returned object is a 1D numpy
|
|
object array of Axes objects.
|
|
- for NxM, subplots with N>1 and M>1 are returned as a 2D array.
|
|
|
|
- If False, no squeezing at all is done: the returned Axes object is
|
|
always a 2D array containing Axes instances, even if it ends up
|
|
being 1x1.
|
|
|
|
width_ratios : array-like of length *ncols*, optional
|
|
Defines the relative widths of the columns. Each column gets a
|
|
relative width of ``width_ratios[i] / sum(width_ratios)``.
|
|
If not given, all columns will have the same width. Equivalent
|
|
to ``gridspec_kw={'width_ratios': [...]}``.
|
|
|
|
height_ratios : array-like of length *nrows*, optional
|
|
Defines the relative heights of the rows. Each row gets a
|
|
relative height of ``height_ratios[i] / sum(height_ratios)``.
|
|
If not given, all rows will have the same height. Convenience
|
|
for ``gridspec_kw={'height_ratios': [...]}``.
|
|
|
|
subplot_kw : dict, optional
|
|
Dict with keywords passed to the
|
|
`~matplotlib.figure.Figure.add_subplot` call used to create each
|
|
subplot.
|
|
|
|
gridspec_kw : dict, optional
|
|
Dict with keywords passed to the `~matplotlib.gridspec.GridSpec`
|
|
constructor used to create the grid the subplots are placed on.
|
|
|
|
**fig_kw
|
|
All additional keyword arguments are passed to the
|
|
`.pyplot.figure` call.
|
|
|
|
Returns
|
|
-------
|
|
fig : `.Figure`
|
|
|
|
ax : `~matplotlib.axes.Axes` or array of Axes
|
|
*ax* can be either a single `~.axes.Axes` object, or an array of Axes
|
|
objects if more than one subplot was created. The dimensions of the
|
|
resulting array can be controlled with the squeeze keyword, see above.
|
|
|
|
Typical idioms for handling the return value are::
|
|
|
|
# using the variable ax for single a Axes
|
|
fig, ax = plt.subplots()
|
|
|
|
# using the variable axs for multiple Axes
|
|
fig, axs = plt.subplots(2, 2)
|
|
|
|
# using tuple unpacking for multiple Axes
|
|
fig, (ax1, ax2) = plt.subplots(1, 2)
|
|
fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2, 2)
|
|
|
|
The names ``ax`` and pluralized ``axs`` are preferred over ``axes``
|
|
because for the latter it's not clear if it refers to a single
|
|
`~.axes.Axes` instance or a collection of these.
|
|
|
|
See Also
|
|
--------
|
|
.pyplot.figure
|
|
.pyplot.subplot
|
|
.pyplot.axes
|
|
.Figure.subplots
|
|
.Figure.add_subplot
|
|
|
|
Examples
|
|
--------
|
|
::
|
|
|
|
# First create some toy data:
|
|
x = np.linspace(0, 2*np.pi, 400)
|
|
y = np.sin(x**2)
|
|
|
|
# Create just a figure and only one subplot
|
|
fig, ax = plt.subplots()
|
|
ax.plot(x, y)
|
|
ax.set_title('Simple plot')
|
|
|
|
# Create two subplots and unpack the output array immediately
|
|
f, (ax1, ax2) = plt.subplots(1, 2, sharey=True)
|
|
ax1.plot(x, y)
|
|
ax1.set_title('Sharing Y axis')
|
|
ax2.scatter(x, y)
|
|
|
|
# Create four polar axes and access them through the returned array
|
|
fig, axs = plt.subplots(2, 2, subplot_kw=dict(projection="polar"))
|
|
axs[0, 0].plot(x, y)
|
|
axs[1, 1].scatter(x, y)
|
|
|
|
# Share a X axis with each column of subplots
|
|
plt.subplots(2, 2, sharex='col')
|
|
|
|
# Share a Y axis with each row of subplots
|
|
plt.subplots(2, 2, sharey='row')
|
|
|
|
# Share both X and Y axes with all subplots
|
|
plt.subplots(2, 2, sharex='all', sharey='all')
|
|
|
|
# Note that this is the same as
|
|
plt.subplots(2, 2, sharex=True, sharey=True)
|
|
|
|
# Create figure number 10 with a single subplot
|
|
# and clears it if it already exists.
|
|
fig, ax = plt.subplots(num=10, clear=True)
|
|
|
|
"""
|
|
...
|
|
|
|
@overload
|
|
def subplot_mosaic(mosaic: str, *, sharex: bool = ..., sharey: bool = ..., width_ratios: ArrayLike | None = ..., height_ratios: ArrayLike | None = ..., empty_sentinel: str = ..., subplot_kw: dict[str, Any] | None = ..., gridspec_kw: dict[str, Any] | None = ..., per_subplot_kw: dict[str | tuple[str, ...], dict[str, Any]] | None = ..., **fig_kw: Any) -> tuple[Figure, dict[str, matplotlib.axes.Axes]]:
|
|
...
|
|
|
|
@overload
|
|
def subplot_mosaic(mosaic: list[HashableList[_T]], *, sharex: bool = ..., sharey: bool = ..., width_ratios: ArrayLike | None = ..., height_ratios: ArrayLike | None = ..., empty_sentinel: _T = ..., subplot_kw: dict[str, Any] | None = ..., gridspec_kw: dict[str, Any] | None = ..., per_subplot_kw: dict[_T | tuple[_T, ...], dict[str, Any]] | None = ..., **fig_kw: Any) -> tuple[Figure, dict[_T, matplotlib.axes.Axes]]:
|
|
...
|
|
|
|
@overload
|
|
def subplot_mosaic(mosaic: list[HashableList[Hashable]], *, sharex: bool = ..., sharey: bool = ..., width_ratios: ArrayLike | None = ..., height_ratios: ArrayLike | None = ..., empty_sentinel: Any = ..., subplot_kw: dict[str, Any] | None = ..., gridspec_kw: dict[str, Any] | None = ..., per_subplot_kw: dict[Hashable | tuple[Hashable, ...], dict[str, Any]] | None = ..., **fig_kw: Any) -> tuple[Figure, dict[Hashable, matplotlib.axes.Axes]]:
|
|
...
|
|
|
|
def subplot_mosaic(mosaic: str | list[HashableList[_T]] | list[HashableList[Hashable]], *, sharex: bool = ..., sharey: bool = ..., width_ratios: ArrayLike | None = ..., height_ratios: ArrayLike | None = ..., empty_sentinel: Any = ..., subplot_kw: dict[str, Any] | None = ..., gridspec_kw: dict[str, Any] | None = ..., per_subplot_kw: dict[str | tuple[str, ...], dict[str, Any]] | dict[_T | tuple[_T, ...], dict[str, Any]] | dict[Hashable | tuple[Hashable, ...], dict[str, Any]] | None = ..., **fig_kw: Any) -> tuple[Figure, dict[str, matplotlib.axes.Axes]] | tuple[Figure, dict[_T, matplotlib.axes.Axes]] | tuple[Figure, dict[Hashable, matplotlib.axes.Axes]]:
|
|
"""
|
|
Build a layout of Axes based on ASCII art or nested lists.
|
|
|
|
This is a helper function to build complex GridSpec layouts visually.
|
|
|
|
See :ref:`mosaic`
|
|
for an example and full API documentation
|
|
|
|
Parameters
|
|
----------
|
|
mosaic : list of list of {hashable or nested} or str
|
|
|
|
A visual layout of how you want your Axes to be arranged
|
|
labeled as strings. For example ::
|
|
|
|
x = [['A panel', 'A panel', 'edge'],
|
|
['C panel', '.', 'edge']]
|
|
|
|
produces 4 axes:
|
|
|
|
- 'A panel' which is 1 row high and spans the first two columns
|
|
- 'edge' which is 2 rows high and is on the right edge
|
|
- 'C panel' which in 1 row and 1 column wide in the bottom left
|
|
- a blank space 1 row and 1 column wide in the bottom center
|
|
|
|
Any of the entries in the layout can be a list of lists
|
|
of the same form to create nested layouts.
|
|
|
|
If input is a str, then it must be of the form ::
|
|
|
|
'''
|
|
AAE
|
|
C.E
|
|
'''
|
|
|
|
where each character is a column and each line is a row.
|
|
This only allows only single character Axes labels and does
|
|
not allow nesting but is very terse.
|
|
|
|
sharex, sharey : bool, default: False
|
|
If True, the x-axis (*sharex*) or y-axis (*sharey*) will be shared
|
|
among all subplots. In that case, tick label visibility and axis units
|
|
behave as for `subplots`. If False, each subplot's x- or y-axis will
|
|
be independent.
|
|
|
|
width_ratios : array-like of length *ncols*, optional
|
|
Defines the relative widths of the columns. Each column gets a
|
|
relative width of ``width_ratios[i] / sum(width_ratios)``.
|
|
If not given, all columns will have the same width. Convenience
|
|
for ``gridspec_kw={'width_ratios': [...]}``.
|
|
|
|
height_ratios : array-like of length *nrows*, optional
|
|
Defines the relative heights of the rows. Each row gets a
|
|
relative height of ``height_ratios[i] / sum(height_ratios)``.
|
|
If not given, all rows will have the same height. Convenience
|
|
for ``gridspec_kw={'height_ratios': [...]}``.
|
|
|
|
empty_sentinel : object, optional
|
|
Entry in the layout to mean "leave this space empty". Defaults
|
|
to ``'.'``. Note, if *layout* is a string, it is processed via
|
|
`inspect.cleandoc` to remove leading white space, which may
|
|
interfere with using white-space as the empty sentinel.
|
|
|
|
subplot_kw : dict, optional
|
|
Dictionary with keywords passed to the `.Figure.add_subplot` call
|
|
used to create each subplot. These values may be overridden by
|
|
values in *per_subplot_kw*.
|
|
|
|
per_subplot_kw : dict, optional
|
|
A dictionary mapping the Axes identifiers or tuples of identifiers
|
|
to a dictionary of keyword arguments to be passed to the
|
|
`.Figure.add_subplot` call used to create each subplot. The values
|
|
in these dictionaries have precedence over the values in
|
|
*subplot_kw*.
|
|
|
|
If *mosaic* is a string, and thus all keys are single characters,
|
|
it is possible to use a single string instead of a tuple as keys;
|
|
i.e. ``"AB"`` is equivalent to ``("A", "B")``.
|
|
|
|
.. versionadded:: 3.7
|
|
|
|
gridspec_kw : dict, optional
|
|
Dictionary with keywords passed to the `.GridSpec` constructor used
|
|
to create the grid the subplots are placed on.
|
|
|
|
**fig_kw
|
|
All additional keyword arguments are passed to the
|
|
`.pyplot.figure` call.
|
|
|
|
Returns
|
|
-------
|
|
fig : `.Figure`
|
|
The new figure
|
|
|
|
dict[label, Axes]
|
|
A dictionary mapping the labels to the Axes objects. The order of
|
|
the axes is left-to-right and top-to-bottom of their position in the
|
|
total layout.
|
|
|
|
"""
|
|
...
|
|
|
|
def subplot2grid(shape: tuple[int, int], loc: tuple[int, int], rowspan: int = ..., colspan: int = ..., fig: Figure | None = ..., **kwargs) -> matplotlib.axes.Axes:
|
|
"""
|
|
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.Axes`
|
|
|
|
The Axes of the subplot. The returned Axes can actually be an instance
|
|
of a subclass, such as `.projections.polar.PolarAxes` for polar
|
|
projections.
|
|
|
|
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])
|
|
"""
|
|
...
|
|
|
|
def twinx(ax: matplotlib.axes.Axes | None = ...) -> _AxesBase:
|
|
"""
|
|
Make and return a second axes that shares the *x*-axis. The new axes will
|
|
overlay *ax* (or the current axes if *ax* is *None*), and its ticks will be
|
|
on the right.
|
|
|
|
Examples
|
|
--------
|
|
:doc:`/gallery/subplots_axes_and_figures/two_scales`
|
|
"""
|
|
...
|
|
|
|
def twiny(ax: matplotlib.axes.Axes | None = ...) -> _AxesBase:
|
|
"""
|
|
Make and return a second axes that shares the *y*-axis. The new axes will
|
|
overlay *ax* (or the current axes if *ax* is *None*), and its ticks will be
|
|
on the top.
|
|
|
|
Examples
|
|
--------
|
|
:doc:`/gallery/subplots_axes_and_figures/two_scales`
|
|
"""
|
|
...
|
|
|
|
def subplot_tool(targetfig: Figure | None = ...) -> SubplotTool | None:
|
|
"""
|
|
Launch a subplot tool window for a figure.
|
|
|
|
Returns
|
|
-------
|
|
`matplotlib.widgets.SubplotTool`
|
|
"""
|
|
...
|
|
|
|
def box(on: bool | None = ...) -> None:
|
|
"""
|
|
Turn the axes box on or off on the current axes.
|
|
|
|
Parameters
|
|
----------
|
|
on : bool or None
|
|
The new `~matplotlib.axes.Axes` box state. If ``None``, toggle
|
|
the state.
|
|
|
|
See Also
|
|
--------
|
|
:meth:`matplotlib.axes.Axes.set_frame_on`
|
|
:meth:`matplotlib.axes.Axes.get_frame_on`
|
|
"""
|
|
...
|
|
|
|
def xlim(*args, **kwargs) -> tuple[float, float]:
|
|
"""
|
|
Get or set the x limits of the current axes.
|
|
|
|
Call signatures::
|
|
|
|
left, right = xlim() # return the current xlim
|
|
xlim((left, right)) # set the xlim to left, right
|
|
xlim(left, right) # set the xlim to left, right
|
|
|
|
If you do not specify args, you can pass *left* or *right* as kwargs,
|
|
i.e.::
|
|
|
|
xlim(right=3) # adjust the right leaving left unchanged
|
|
xlim(left=1) # adjust the left leaving right unchanged
|
|
|
|
Setting limits turns autoscaling off for the x-axis.
|
|
|
|
Returns
|
|
-------
|
|
left, right
|
|
A tuple of the new x-axis limits.
|
|
|
|
Notes
|
|
-----
|
|
Calling this function with no arguments (e.g. ``xlim()``) is the pyplot
|
|
equivalent of calling `~.Axes.get_xlim` on the current axes.
|
|
Calling this function with arguments is the pyplot equivalent of calling
|
|
`~.Axes.set_xlim` on the current axes. All arguments are passed though.
|
|
"""
|
|
...
|
|
|
|
def ylim(*args, **kwargs) -> tuple[float, float]:
|
|
"""
|
|
Get or set the y-limits of the current axes.
|
|
|
|
Call signatures::
|
|
|
|
bottom, top = ylim() # return the current ylim
|
|
ylim((bottom, top)) # set the ylim to bottom, top
|
|
ylim(bottom, top) # set the ylim to bottom, top
|
|
|
|
If you do not specify args, you can alternatively pass *bottom* or
|
|
*top* as kwargs, i.e.::
|
|
|
|
ylim(top=3) # adjust the top leaving bottom unchanged
|
|
ylim(bottom=1) # adjust the bottom leaving top unchanged
|
|
|
|
Setting limits turns autoscaling off for the y-axis.
|
|
|
|
Returns
|
|
-------
|
|
bottom, top
|
|
A tuple of the new y-axis limits.
|
|
|
|
Notes
|
|
-----
|
|
Calling this function with no arguments (e.g. ``ylim()``) is the pyplot
|
|
equivalent of calling `~.Axes.get_ylim` on the current axes.
|
|
Calling this function with arguments is the pyplot equivalent of calling
|
|
`~.Axes.set_ylim` on the current axes. All arguments are passed though.
|
|
"""
|
|
...
|
|
|
|
def xticks(ticks: ArrayLike | None = ..., labels: Sequence[str] | None = ..., *, minor: bool = ..., **kwargs) -> tuple[list[Tick] | np.ndarray, list[Text]]:
|
|
"""
|
|
Get or set the current tick locations and labels of the x-axis.
|
|
|
|
Pass no arguments to return the current values without modifying them.
|
|
|
|
Parameters
|
|
----------
|
|
ticks : array-like, optional
|
|
The list of xtick locations. Passing an empty list removes all xticks.
|
|
labels : array-like, optional
|
|
The labels to place at the given *ticks* locations. This argument can
|
|
only be passed if *ticks* is passed as well.
|
|
minor : bool, default: False
|
|
If ``False``, get/set the major ticks/labels; if ``True``, the minor
|
|
ticks/labels.
|
|
**kwargs
|
|
`.Text` properties can be used to control the appearance of the labels.
|
|
|
|
Returns
|
|
-------
|
|
locs
|
|
The list of xtick locations.
|
|
labels
|
|
The list of xlabel `.Text` objects.
|
|
|
|
Notes
|
|
-----
|
|
Calling this function with no arguments (e.g. ``xticks()``) is the pyplot
|
|
equivalent of calling `~.Axes.get_xticks` and `~.Axes.get_xticklabels` on
|
|
the current axes.
|
|
Calling this function with arguments is the pyplot equivalent of calling
|
|
`~.Axes.set_xticks` and `~.Axes.set_xticklabels` on the current axes.
|
|
|
|
Examples
|
|
--------
|
|
>>> locs, labels = xticks() # Get the current locations and labels.
|
|
>>> xticks(np.arange(0, 1, step=0.2)) # Set label locations.
|
|
>>> xticks(np.arange(3), ['Tom', 'Dick', 'Sue']) # Set text labels.
|
|
>>> xticks([0, 1, 2], ['January', 'February', 'March'],
|
|
... rotation=20) # Set text labels and properties.
|
|
>>> xticks([]) # Disable xticks.
|
|
"""
|
|
...
|
|
|
|
def yticks(ticks: ArrayLike | None = ..., labels: Sequence[str] | None = ..., *, minor: bool = ..., **kwargs) -> tuple[list[Tick] | np.ndarray, list[Text]]:
|
|
"""
|
|
Get or set the current tick locations and labels of the y-axis.
|
|
|
|
Pass no arguments to return the current values without modifying them.
|
|
|
|
Parameters
|
|
----------
|
|
ticks : array-like, optional
|
|
The list of ytick locations. Passing an empty list removes all yticks.
|
|
labels : array-like, optional
|
|
The labels to place at the given *ticks* locations. This argument can
|
|
only be passed if *ticks* is passed as well.
|
|
minor : bool, default: False
|
|
If ``False``, get/set the major ticks/labels; if ``True``, the minor
|
|
ticks/labels.
|
|
**kwargs
|
|
`.Text` properties can be used to control the appearance of the labels.
|
|
|
|
Returns
|
|
-------
|
|
locs
|
|
The list of ytick locations.
|
|
labels
|
|
The list of ylabel `.Text` objects.
|
|
|
|
Notes
|
|
-----
|
|
Calling this function with no arguments (e.g. ``yticks()``) is the pyplot
|
|
equivalent of calling `~.Axes.get_yticks` and `~.Axes.get_yticklabels` on
|
|
the current axes.
|
|
Calling this function with arguments is the pyplot equivalent of calling
|
|
`~.Axes.set_yticks` and `~.Axes.set_yticklabels` on the current axes.
|
|
|
|
Examples
|
|
--------
|
|
>>> locs, labels = yticks() # Get the current locations and labels.
|
|
>>> yticks(np.arange(0, 1, step=0.2)) # Set label locations.
|
|
>>> yticks(np.arange(3), ['Tom', 'Dick', 'Sue']) # Set text labels.
|
|
>>> yticks([0, 1, 2], ['January', 'February', 'March'],
|
|
... rotation=45) # Set text labels and properties.
|
|
>>> yticks([]) # Disable yticks.
|
|
"""
|
|
...
|
|
|
|
def rgrids(radii: ArrayLike | None = ..., labels: Sequence[str | Text] | None = ..., angle: float | None = ..., fmt: str | None = ..., **kwargs) -> tuple[list[Line2D], list[Text]]:
|
|
"""
|
|
Get or set the radial gridlines on the current polar plot.
|
|
|
|
Call signatures::
|
|
|
|
lines, labels = rgrids()
|
|
lines, labels = rgrids(radii, labels=None, angle=22.5, fmt=None, **kwargs)
|
|
|
|
When called with no arguments, `.rgrids` simply returns the tuple
|
|
(*lines*, *labels*). When called with arguments, the labels will
|
|
appear at the specified radial distances and angle.
|
|
|
|
Parameters
|
|
----------
|
|
radii : tuple with floats
|
|
The radii for the radial gridlines
|
|
|
|
labels : tuple with strings or None
|
|
The labels to use at each radial gridline. The
|
|
`matplotlib.ticker.ScalarFormatter` will be used if None.
|
|
|
|
angle : float
|
|
The angular position of the radius labels in degrees.
|
|
|
|
fmt : str or None
|
|
Format string used in `matplotlib.ticker.FormatStrFormatter`.
|
|
For example '%f'.
|
|
|
|
Returns
|
|
-------
|
|
lines : list of `.lines.Line2D`
|
|
The radial gridlines.
|
|
|
|
labels : list of `.text.Text`
|
|
The tick labels.
|
|
|
|
Other Parameters
|
|
----------------
|
|
**kwargs
|
|
*kwargs* are optional `.Text` properties for the labels.
|
|
|
|
See Also
|
|
--------
|
|
.pyplot.thetagrids
|
|
.projections.polar.PolarAxes.set_rgrids
|
|
.Axis.get_gridlines
|
|
.Axis.get_ticklabels
|
|
|
|
Examples
|
|
--------
|
|
::
|
|
|
|
# set the locations of the radial gridlines
|
|
lines, labels = rgrids( (0.25, 0.5, 1.0) )
|
|
|
|
# set the locations and labels of the radial gridlines
|
|
lines, labels = rgrids( (0.25, 0.5, 1.0), ('Tom', 'Dick', 'Harry' ))
|
|
"""
|
|
...
|
|
|
|
def thetagrids(angles: ArrayLike | None = ..., labels: Sequence[str | Text] | None = ..., fmt: str | None = ..., **kwargs) -> tuple[list[Line2D], list[Text]]:
|
|
"""
|
|
Get or set the theta gridlines on the current polar plot.
|
|
|
|
Call signatures::
|
|
|
|
lines, labels = thetagrids()
|
|
lines, labels = thetagrids(angles, labels=None, fmt=None, **kwargs)
|
|
|
|
When called with no arguments, `.thetagrids` simply returns the tuple
|
|
(*lines*, *labels*). When called with arguments, the labels will
|
|
appear at the specified angles.
|
|
|
|
Parameters
|
|
----------
|
|
angles : tuple with floats, degrees
|
|
The angles of the theta gridlines.
|
|
|
|
labels : tuple with strings or None
|
|
The labels to use at each radial gridline. The
|
|
`.projections.polar.ThetaFormatter` will be used if None.
|
|
|
|
fmt : str or None
|
|
Format string used in `matplotlib.ticker.FormatStrFormatter`.
|
|
For example '%f'. Note that the angle in radians will be used.
|
|
|
|
Returns
|
|
-------
|
|
lines : list of `.lines.Line2D`
|
|
The theta gridlines.
|
|
|
|
labels : list of `.text.Text`
|
|
The tick labels.
|
|
|
|
Other Parameters
|
|
----------------
|
|
**kwargs
|
|
*kwargs* are optional `.Text` properties for the labels.
|
|
|
|
See Also
|
|
--------
|
|
.pyplot.rgrids
|
|
.projections.polar.PolarAxes.set_thetagrids
|
|
.Axis.get_gridlines
|
|
.Axis.get_ticklabels
|
|
|
|
Examples
|
|
--------
|
|
::
|
|
|
|
# set the locations of the angular gridlines
|
|
lines, labels = thetagrids(range(45, 360, 90))
|
|
|
|
# set the locations and labels of the angular gridlines
|
|
lines, labels = thetagrids(range(45, 360, 90), ('NE', 'NW', 'SW', 'SE'))
|
|
"""
|
|
...
|
|
|
|
@_api.deprecated("3.7", pending=True)
|
|
def get_plot_commands() -> list[str]:
|
|
"""
|
|
Get a sorted list of all of the plotting commands.
|
|
"""
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Figure.colorbar)
|
|
def colorbar(mappable: ScalarMappable | None = ..., cax: matplotlib.axes.Axes | None = ..., ax: matplotlib.axes.Axes | Iterable[matplotlib.axes.Axes] | None = ..., **kwargs) -> Colorbar:
|
|
...
|
|
|
|
def clim(vmin: float | None = ..., vmax: float | None = ...) -> None:
|
|
"""
|
|
Set the color limits of the current image.
|
|
|
|
If either *vmin* or *vmax* is None, the image min/max respectively
|
|
will be used for color scaling.
|
|
|
|
If you want to set the clim of multiple images, use
|
|
`~.ScalarMappable.set_clim` on every image, for example::
|
|
|
|
for im in gca().get_images():
|
|
im.set_clim(0, 0.5)
|
|
|
|
"""
|
|
...
|
|
|
|
def get_cmap(name: Colormap | str | None = ..., lut: int | None = ...) -> Colormap:
|
|
...
|
|
|
|
def set_cmap(cmap: Colormap | str) -> None:
|
|
"""
|
|
Set the default colormap, and applies it to the current image if any.
|
|
|
|
Parameters
|
|
----------
|
|
cmap : `~matplotlib.colors.Colormap` or str
|
|
A colormap instance or the name of a registered colormap.
|
|
|
|
See Also
|
|
--------
|
|
colormaps
|
|
matplotlib.cm.register_cmap
|
|
matplotlib.cm.get_cmap
|
|
"""
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(matplotlib.image.imread)
|
|
def imread(fname: str | pathlib.Path | BinaryIO, format: str | None = ...) -> np.ndarray:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(matplotlib.image.imsave)
|
|
def imsave(fname: str | os.PathLike | BinaryIO, arr: ArrayLike, **kwargs) -> None:
|
|
...
|
|
|
|
def matshow(A: ArrayLike, fignum: None | int = ..., **kwargs) -> AxesImage:
|
|
"""
|
|
Display an array as a matrix in a new figure window.
|
|
|
|
The origin is set at the upper left hand corner and rows (first
|
|
dimension of the array) are displayed horizontally. The aspect
|
|
ratio of the figure window is that of the array, unless this would
|
|
make an excessively short or narrow figure.
|
|
|
|
Tick labels for the xaxis are placed on top.
|
|
|
|
Parameters
|
|
----------
|
|
A : 2D array-like
|
|
The matrix to be displayed.
|
|
|
|
fignum : None or int
|
|
If *None*, create a new figure window with automatic numbering.
|
|
|
|
If a nonzero integer, draw into the figure with the given number
|
|
(create it if it does not exist).
|
|
|
|
If 0, use the current axes (or create one if it does not exist).
|
|
|
|
.. note::
|
|
|
|
Because of how `.Axes.matshow` tries to set the figure aspect
|
|
ratio to be the one of the array, strange things may happen if you
|
|
reuse an existing figure.
|
|
|
|
Returns
|
|
-------
|
|
`~matplotlib.image.AxesImage`
|
|
|
|
Other Parameters
|
|
----------------
|
|
**kwargs : `~matplotlib.axes.Axes.imshow` arguments
|
|
|
|
"""
|
|
...
|
|
|
|
def polar(*args, **kwargs) -> list[Line2D]:
|
|
"""
|
|
Make a polar plot.
|
|
|
|
call signature::
|
|
|
|
polar(theta, r, **kwargs)
|
|
|
|
Multiple *theta*, *r* arguments are supported, with format strings, as in
|
|
`plot`.
|
|
"""
|
|
...
|
|
|
|
if (rcParams["backend_fallback"] and rcParams._get_backend_or_none() in (set(rcsetup.interactive_bk) - 'WebAgg', 'nbAgg') and cbook._get_running_interactive_framework()):
|
|
...
|
|
@_copy_docstring_and_deprecators(Figure.figimage)
|
|
def figimage(X: ArrayLike, xo: int = ..., yo: int = ..., alpha: float | None = ..., norm: str | Normalize | None = ..., cmap: str | Colormap | None = ..., vmin: float | None = ..., vmax: float | None = ..., origin: Literal["upper", "lower"] | None = ..., resize: bool = ..., **kwargs) -> FigureImage:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Figure.text)
|
|
def figtext(x: float, y: float, s: str, fontdict: dict[str, Any] | None = ..., **kwargs) -> Text:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Figure.gca)
|
|
def gca() -> Axes:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Figure._gci)
|
|
def gci() -> ScalarMappable | None:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Figure.ginput)
|
|
def ginput(n: int = ..., timeout: float = ..., show_clicks: bool = ..., mouse_add: MouseButton = ..., mouse_pop: MouseButton = ..., mouse_stop: MouseButton = ...) -> list[tuple[int, int]]:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Figure.subplots_adjust)
|
|
def subplots_adjust(left: float | None = ..., bottom: float | None = ..., right: float | None = ..., top: float | None = ..., wspace: float | None = ..., hspace: float | None = ...) -> None:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Figure.suptitle)
|
|
def suptitle(t: str, **kwargs) -> Text:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Figure.tight_layout)
|
|
def tight_layout(*, pad: float = ..., h_pad: float | None = ..., w_pad: float | None = ..., rect: tuple[float, float, float, float] | None = ...) -> None:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Figure.waitforbuttonpress)
|
|
def waitforbuttonpress(timeout: float = ...) -> None | bool:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.acorr)
|
|
def acorr(x: ArrayLike, *, data=..., **kwargs) -> tuple[np.ndarray, np.ndarray, LineCollection | Line2D, Line2D | None]:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.angle_spectrum)
|
|
def angle_spectrum(x: ArrayLike, Fs: float | None = ..., Fc: int | None = ..., window: Callable[[ArrayLike], ArrayLike] | ArrayLike | None = ..., pad_to: int | None = ..., sides: Literal["default", "onesided", "twosided"] | None = ..., *, data=..., **kwargs) -> tuple[np.ndarray, np.ndarray, Line2D]:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.annotate)
|
|
def annotate(text: str, xy: tuple[float, float], xytext: tuple[float, float] | None = ..., xycoords: str | Artist | Transform | Callable[[RendererBase], Bbox | Transform] | tuple[float, float] = ..., textcoords: str | Artist | Transform | Callable[[RendererBase], Bbox | Transform] | tuple[float, float] | None = ..., arrowprops: dict[str, Any] | None = ..., annotation_clip: bool | None = ..., **kwargs) -> Annotation:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.arrow)
|
|
def arrow(x: float, y: float, dx: float, dy: float, **kwargs) -> FancyArrow:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.autoscale)
|
|
def autoscale(enable: bool = ..., axis: Literal["both", "x", "y"] = ..., tight: bool | None = ...) -> None:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.axhline)
|
|
def axhline(y: float = ..., xmin: float = ..., xmax: float = ..., **kwargs) -> Line2D:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.axhspan)
|
|
def axhspan(ymin: float, ymax: float, xmin: float = ..., xmax: float = ..., **kwargs) -> Polygon:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.axis)
|
|
def axis(arg: tuple[float, float, float, float] | bool | str | None = ..., /, *, emit: bool = ..., **kwargs) -> tuple[float, float, float, float]:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.axline)
|
|
def axline(xy1: tuple[float, float], xy2: tuple[float, float] | None = ..., *, slope: float | None = ..., **kwargs) -> Line2D:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.axvline)
|
|
def axvline(x: float = ..., ymin: float = ..., ymax: float = ..., **kwargs) -> Line2D:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.axvspan)
|
|
def axvspan(xmin: float, xmax: float, ymin: float = ..., ymax: float = ..., **kwargs) -> Polygon:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.bar)
|
|
def bar(x: float | ArrayLike, height: float | ArrayLike, width: float | ArrayLike = ..., bottom: float | ArrayLike | None = ..., *, align: Literal["center", "edge"] = ..., data=..., **kwargs) -> BarContainer:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.barbs)
|
|
def barbs(*args, data=..., **kwargs) -> Barbs:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.barh)
|
|
def barh(y: float | ArrayLike, width: float | ArrayLike, height: float | ArrayLike = ..., left: float | ArrayLike | None = ..., *, align: Literal["center", "edge"] = ..., data=..., **kwargs) -> BarContainer:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.bar_label)
|
|
def bar_label(container: BarContainer, labels: ArrayLike | None = ..., *, fmt: str | Callable[[float], str] = ..., label_type: Literal["center", "edge"] = ..., padding: float = ..., **kwargs) -> list[Annotation]:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.boxplot)
|
|
def boxplot(x: ArrayLike | Sequence[ArrayLike], notch: bool | None = ..., sym: str | None = ..., vert: bool | None = ..., whis: float | tuple[float, float] | None = ..., positions: ArrayLike | None = ..., widths: float | ArrayLike | None = ..., patch_artist: bool | None = ..., bootstrap: int | None = ..., usermedians: ArrayLike | None = ..., conf_intervals: ArrayLike | None = ..., meanline: bool | None = ..., showmeans: bool | None = ..., showcaps: bool | None = ..., showbox: bool | None = ..., showfliers: bool | None = ..., boxprops: dict[str, Any] | None = ..., labels: Sequence[str] | None = ..., flierprops: dict[str, Any] | None = ..., medianprops: dict[str, Any] | None = ..., meanprops: dict[str, Any] | None = ..., capprops: dict[str, Any] | None = ..., whiskerprops: dict[str, Any] | None = ..., manage_ticks: bool = ..., autorange: bool = ..., zorder: float | None = ..., capwidths: float | ArrayLike | None = ..., *, data=...) -> dict[str, Any]:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.broken_barh)
|
|
def broken_barh(xranges: Sequence[tuple[float, float]], yrange: tuple[float, float], *, data=..., **kwargs) -> BrokenBarHCollection:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.clabel)
|
|
def clabel(CS: ContourSet, levels: ArrayLike | None = ..., **kwargs) -> list[Text]:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.cohere)
|
|
def cohere(x: ArrayLike, y: ArrayLike, NFFT: int = ..., Fs: float = ..., Fc: int = ..., detrend: Literal["none", "mean", "linear"] | Callable[[ArrayLike], ArrayLike] = ..., window: Callable[[ArrayLike], ArrayLike] | ArrayLike = ..., noverlap: int = ..., pad_to: int | None = ..., sides: Literal["default", "onesided", "twosided"] = ..., scale_by_freq: bool | None = ..., *, data=..., **kwargs) -> tuple[np.ndarray, np.ndarray]:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.contour)
|
|
def contour(*args, data=..., **kwargs) -> QuadContourSet:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.contourf)
|
|
def contourf(*args, data=..., **kwargs) -> QuadContourSet:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.csd)
|
|
def csd(x: ArrayLike, y: ArrayLike, NFFT: int | None = ..., Fs: float | None = ..., Fc: int | None = ..., detrend: Literal["none", "mean", "linear"] | Callable[[ArrayLike], ArrayLike] | None = ..., window: Callable[[ArrayLike], ArrayLike] | ArrayLike | None = ..., noverlap: int | None = ..., pad_to: int | None = ..., sides: Literal["default", "onesided", "twosided"] | None = ..., scale_by_freq: bool | None = ..., return_line: bool | None = ..., *, data=..., **kwargs) -> tuple[np.ndarray, np.ndarray] | tuple[np.ndarray, np.ndarray, Line2D]:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.ecdf)
|
|
def ecdf(x: ArrayLike, weights: ArrayLike | None = ..., *, complementary: bool = ..., orientation: Literal["vertical", "horizonatal"] = ..., compress: bool = ..., data=..., **kwargs) -> Line2D:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.errorbar)
|
|
def errorbar(x: float | ArrayLike, y: float | ArrayLike, yerr: float | ArrayLike | None = ..., xerr: float | ArrayLike | None = ..., fmt: str = ..., ecolor: ColorType | None = ..., elinewidth: float | None = ..., capsize: float | None = ..., barsabove: bool = ..., lolims: bool | ArrayLike = ..., uplims: bool | ArrayLike = ..., xlolims: bool | ArrayLike = ..., xuplims: bool | ArrayLike = ..., errorevery: int | tuple[int, int] = ..., capthick: float | None = ..., *, data=..., **kwargs) -> ErrorbarContainer:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.eventplot)
|
|
def eventplot(positions: ArrayLike | Sequence[ArrayLike], orientation: Literal["horizontal", "vertical"] = ..., lineoffsets: float | Sequence[float] = ..., linelengths: float | Sequence[float] = ..., linewidths: float | Sequence[float] | None = ..., colors: ColorType | Sequence[ColorType] | None = ..., alpha: float | Sequence[float] | None = ..., linestyles: LineStyleType | Sequence[LineStyleType] = ..., *, data=..., **kwargs) -> EventCollection:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.fill)
|
|
def fill(*args, data=..., **kwargs) -> list[Polygon]:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.fill_between)
|
|
def fill_between(x: ArrayLike, y1: ArrayLike | float, y2: ArrayLike | float = ..., where: Sequence[bool] | None = ..., interpolate: bool = ..., step: Literal["pre", "post", "mid"] | None = ..., *, data=..., **kwargs) -> PolyCollection:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.fill_betweenx)
|
|
def fill_betweenx(y: ArrayLike, x1: ArrayLike | float, x2: ArrayLike | float = ..., where: Sequence[bool] | None = ..., step: Literal["pre", "post", "mid"] | None = ..., interpolate: bool = ..., *, data=..., **kwargs) -> PolyCollection:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.grid)
|
|
def grid(visible: bool | None = ..., which: Literal["major", "minor", "both"] = ..., axis: Literal["both", "x", "y"] = ..., **kwargs) -> None:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.hexbin)
|
|
def hexbin(x: ArrayLike, y: ArrayLike, C: ArrayLike | None = ..., gridsize: int | tuple[int, int] = ..., bins: Literal["log"] | int | Sequence[float] | None = ..., xscale: Literal["linear", "log"] = ..., yscale: Literal["linear", "log"] = ..., extent: tuple[float, float, float, float] | None = ..., cmap: str | Colormap | None = ..., norm: str | Normalize | None = ..., vmin: float | None = ..., vmax: float | None = ..., alpha: float | None = ..., linewidths: float | None = ..., edgecolors: Literal["face", "none"] | ColorType = ..., reduce_C_function: Callable[[np.ndarray | list[float]], float] = ..., mincnt: int | None = ..., marginals: bool = ..., *, data=..., **kwargs) -> PolyCollection:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.hist)
|
|
def hist(x: ArrayLike | Sequence[ArrayLike], bins: int | Sequence[float] | str | None = ..., range: tuple[float, float] | None = ..., density: bool = ..., weights: ArrayLike | None = ..., cumulative: bool | float = ..., bottom: ArrayLike | float | None = ..., histtype: Literal["bar", "barstacked", "step", "stepfilled"] = ..., align: Literal["left", "mid", "right"] = ..., orientation: Literal["vertical", "horizontal"] = ..., rwidth: float | None = ..., log: bool = ..., color: ColorType | Sequence[ColorType] | None = ..., label: str | Sequence[str] | None = ..., stacked: bool = ..., *, data=..., **kwargs) -> tuple[np.ndarray | list[np.ndarray], np.ndarray, BarContainer | Polygon | list[BarContainer | Polygon],]:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.stairs)
|
|
def stairs(values: ArrayLike, edges: ArrayLike | None = ..., *, orientation: Literal["vertical", "horizontal"] = ..., baseline: float | ArrayLike | None = ..., fill: bool = ..., data=..., **kwargs) -> StepPatch:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.hist2d)
|
|
def hist2d(x: ArrayLike, y: ArrayLike, bins: None | int | tuple[int, int] | ArrayLike | tuple[ArrayLike, ArrayLike] = ..., range: ArrayLike | None = ..., density: bool = ..., weights: ArrayLike | None = ..., cmin: float | None = ..., cmax: float | None = ..., *, data=..., **kwargs) -> tuple[np.ndarray, np.ndarray, np.ndarray, QuadMesh]:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.hlines)
|
|
def hlines(y: float | ArrayLike, xmin: float | ArrayLike, xmax: float | ArrayLike, colors: ColorType | Sequence[ColorType] | None = ..., linestyles: LineStyleType = ..., label: str = ..., *, data=..., **kwargs) -> LineCollection:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.imshow)
|
|
def imshow(X: ArrayLike | PIL.Image.Image, cmap: str | Colormap | None = ..., norm: str | Normalize | None = ..., *, aspect: Literal["equal", "auto"] | float | None = ..., interpolation: str | None = ..., alpha: float | ArrayLike | None = ..., vmin: float | None = ..., vmax: float | None = ..., origin: Literal["upper", "lower"] | None = ..., extent: tuple[float, float, float, float] | None = ..., interpolation_stage: Literal["data", "rgba"] | None = ..., filternorm: bool = ..., filterrad: float = ..., resample: bool | None = ..., url: str | None = ..., data=..., **kwargs) -> AxesImage:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.legend)
|
|
def legend(*args, **kwargs) -> Legend:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.locator_params)
|
|
def locator_params(axis: Literal["both", "x", "y"] = ..., tight: bool | None = ..., **kwargs) -> None:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.loglog)
|
|
def loglog(*args, **kwargs) -> list[Line2D]:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.magnitude_spectrum)
|
|
def magnitude_spectrum(x: ArrayLike, Fs: float | None = ..., Fc: int | None = ..., window: Callable[[ArrayLike], ArrayLike] | ArrayLike | None = ..., pad_to: int | None = ..., sides: Literal["default", "onesided", "twosided"] | None = ..., scale: Literal["default", "linear", "dB"] | None = ..., *, data=..., **kwargs) -> tuple[np.ndarray, np.ndarray, Line2D]:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.margins)
|
|
def margins(*margins: float, x: float | None = ..., y: float | None = ..., tight: bool | None = ...) -> tuple[float, float] | None:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.minorticks_off)
|
|
def minorticks_off() -> None:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.minorticks_on)
|
|
def minorticks_on() -> None:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.pcolor)
|
|
def pcolor(*args: ArrayLike, shading: Literal["flat", "nearest", "auto"] | None = ..., alpha: float | None = ..., norm: str | Normalize | None = ..., cmap: str | Colormap | None = ..., vmin: float | None = ..., vmax: float | None = ..., data=..., **kwargs) -> Collection:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.pcolormesh)
|
|
def pcolormesh(*args: ArrayLike, alpha: float | None = ..., norm: str | Normalize | None = ..., cmap: str | Colormap | None = ..., vmin: float | None = ..., vmax: float | None = ..., shading: Literal["flat", "nearest", "gouraud", "auto"] | None = ..., antialiased: bool = ..., data=..., **kwargs) -> QuadMesh:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.phase_spectrum)
|
|
def phase_spectrum(x: ArrayLike, Fs: float | None = ..., Fc: int | None = ..., window: Callable[[ArrayLike], ArrayLike] | ArrayLike | None = ..., pad_to: int | None = ..., sides: Literal["default", "onesided", "twosided"] | None = ..., *, data=..., **kwargs) -> tuple[np.ndarray, np.ndarray, Line2D]:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.pie)
|
|
def pie(x: ArrayLike, explode: ArrayLike | None = ..., labels: Sequence[str] | None = ..., colors: ColorType | Sequence[ColorType] | None = ..., autopct: str | Callable[[float], str] | None = ..., pctdistance: float = ..., shadow: bool = ..., labeldistance: float | None = ..., startangle: float = ..., radius: float = ..., counterclock: bool = ..., wedgeprops: dict[str, Any] | None = ..., textprops: dict[str, Any] | None = ..., center: tuple[float, float] = ..., frame: bool = ..., rotatelabels: bool = ..., *, normalize: bool = ..., hatch: str | Sequence[str] | None = ..., data=...) -> tuple[list[Wedge], list[Text]] | tuple[list[Wedge], list[Text], list[Text]]:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.plot)
|
|
def plot(*args: float | ArrayLike | str, scalex: bool = ..., scaley: bool = ..., data=..., **kwargs) -> list[Line2D]:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.plot_date)
|
|
def plot_date(x: ArrayLike, y: ArrayLike, fmt: str = ..., tz: str | datetime.tzinfo | None = ..., xdate: bool = ..., ydate: bool = ..., *, data=..., **kwargs) -> list[Line2D]:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.psd)
|
|
def psd(x: ArrayLike, NFFT: int | None = ..., Fs: float | None = ..., Fc: int | None = ..., detrend: Literal["none", "mean", "linear"] | Callable[[ArrayLike], ArrayLike] | None = ..., window: Callable[[ArrayLike], ArrayLike] | ArrayLike | None = ..., noverlap: int | None = ..., pad_to: int | None = ..., sides: Literal["default", "onesided", "twosided"] | None = ..., scale_by_freq: bool | None = ..., return_line: bool | None = ..., *, data=..., **kwargs) -> tuple[np.ndarray, np.ndarray] | tuple[np.ndarray, np.ndarray, Line2D]:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.quiver)
|
|
def quiver(*args, data=..., **kwargs) -> Quiver:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.quiverkey)
|
|
def quiverkey(Q: Quiver, X: float, Y: float, U: float, label: str, **kwargs) -> QuiverKey:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.scatter)
|
|
def scatter(x: float | ArrayLike, y: float | ArrayLike, s: float | ArrayLike | None = ..., c: Sequence[ColorType] | ColorType | None = ..., marker: MarkerType | None = ..., cmap: str | Colormap | None = ..., norm: str | Normalize | None = ..., vmin: float | None = ..., vmax: float | None = ..., alpha: float | None = ..., linewidths: float | Sequence[float] | None = ..., *, edgecolors: Literal["face", "none"] | ColorType | Sequence[ColorType] | None = ..., plotnonfinite: bool = ..., data=..., **kwargs) -> PathCollection:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.semilogx)
|
|
def semilogx(*args, **kwargs) -> list[Line2D]:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.semilogy)
|
|
def semilogy(*args, **kwargs) -> list[Line2D]:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.specgram)
|
|
def specgram(x: ArrayLike, NFFT: int | None = ..., Fs: float | None = ..., Fc: int | None = ..., detrend: Literal["none", "mean", "linear"] | Callable[[ArrayLike], ArrayLike] | None = ..., window: Callable[[ArrayLike], ArrayLike] | ArrayLike | None = ..., noverlap: int | None = ..., cmap: str | Colormap | None = ..., xextent: tuple[float, float] | None = ..., pad_to: int | None = ..., sides: Literal["default", "onesided", "twosided"] | None = ..., scale_by_freq: bool | None = ..., mode: Literal["default", "psd", "magnitude", "angle", "phase"] | None = ..., scale: Literal["default", "linear", "dB"] | None = ..., vmin: float | None = ..., vmax: float | None = ..., *, data=..., **kwargs) -> tuple[np.ndarray, np.ndarray, np.ndarray, AxesImage]:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.spy)
|
|
def spy(Z: ArrayLike, precision: float | Literal["present"] = ..., marker: str | None = ..., markersize: float | None = ..., aspect: Literal["equal", "auto"] | float | None = ..., origin: Literal["upper", "lower"] = ..., **kwargs) -> AxesImage:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.stackplot)
|
|
def stackplot(x, *args, labels=..., colors=..., baseline=..., data=..., **kwargs): # -> list[PolyCollection]:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.stem)
|
|
def stem(*args: ArrayLike | str, linefmt: str | None = ..., markerfmt: str | None = ..., basefmt: str | None = ..., bottom: float = ..., label: str | None = ..., orientation: Literal["vertical", "horizontal"] = ..., data=...) -> StemContainer:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.step)
|
|
def step(x: ArrayLike, y: ArrayLike, *args, where: Literal["pre", "post", "mid"] = ..., data=..., **kwargs) -> list[Line2D]:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.streamplot)
|
|
def streamplot(x, y, u, v, density=..., linewidth=..., color=..., cmap=..., norm=..., arrowsize=..., arrowstyle=..., minlength=..., transform=..., zorder=..., start_points=..., maxlength=..., integration_direction=..., broken_streamlines=..., *, data=...): # -> StreamplotSet:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.table)
|
|
def table(cellText=..., cellColours=..., cellLoc=..., colWidths=..., rowLabels=..., rowColours=..., rowLoc=..., colLabels=..., colColours=..., colLoc=..., loc=..., bbox=..., edges=..., **kwargs): # -> Table:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.text)
|
|
def text(x: float, y: float, s: str, fontdict: dict[str, Any] | None = ..., **kwargs) -> Text:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.tick_params)
|
|
def tick_params(axis: Literal["both", "x", "y"] = ..., **kwargs) -> None:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.ticklabel_format)
|
|
def ticklabel_format(*, axis: Literal["both", "x", "y"] = ..., style: Literal["", "sci", "scientific", "plain"] = ..., scilimits: tuple[int, int] | None = ..., useOffset: bool | float | None = ..., useLocale: bool | None = ..., useMathText: bool | None = ...) -> None:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.tricontour)
|
|
def tricontour(*args, **kwargs): # -> TriContourSet:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.tricontourf)
|
|
def tricontourf(*args, **kwargs): # -> TriContourSet:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.tripcolor)
|
|
def tripcolor(*args, alpha=..., norm=..., cmap=..., vmin=..., vmax=..., shading=..., facecolors=..., **kwargs):
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.triplot)
|
|
def triplot(*args, **kwargs): # -> tuple[Line2D, Line2D]:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.violinplot)
|
|
def violinplot(dataset: ArrayLike | Sequence[ArrayLike], positions: ArrayLike | None = ..., vert: bool = ..., widths: float | ArrayLike = ..., showmeans: bool = ..., showextrema: bool = ..., showmedians: bool = ..., quantiles: Sequence[float | Sequence[float]] | None = ..., points: int = ..., bw_method: Literal["scott", "silverman"] | float | Callable[[GaussianKDE], float] | None = ..., *, data=...) -> dict[str, Collection]:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.vlines)
|
|
def vlines(x: float | ArrayLike, ymin: float | ArrayLike, ymax: float | ArrayLike, colors: ColorType | Sequence[ColorType] | None = ..., linestyles: LineStyleType = ..., label: str = ..., *, data=..., **kwargs) -> LineCollection:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.xcorr)
|
|
def xcorr(x: ArrayLike, y: ArrayLike, normed: bool = ..., detrend: Callable[[ArrayLike], ArrayLike] = ..., usevlines: bool = ..., maxlags: int = ..., *, data=..., **kwargs) -> tuple[np.ndarray, np.ndarray, LineCollection | Line2D, Line2D | None]:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes._sci)
|
|
def sci(im: ScalarMappable) -> None:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.set_title)
|
|
def title(label: str, fontdict: dict[str, Any] | None = ..., loc: Literal["left", "center", "right"] | None = ..., pad: float | None = ..., *, y: float | None = ..., **kwargs) -> Text:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.set_xlabel)
|
|
def xlabel(xlabel: str, fontdict: dict[str, Any] | None = ..., labelpad: float | None = ..., *, loc: Literal["left", "center", "right"] | None = ..., **kwargs) -> Text:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.set_ylabel)
|
|
def ylabel(ylabel: str, fontdict: dict[str, Any] | None = ..., labelpad: float | None = ..., *, loc: Literal["bottom", "center", "top"] | None = ..., **kwargs) -> Text:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.set_xscale)
|
|
def xscale(value: str | ScaleBase, **kwargs) -> None:
|
|
...
|
|
|
|
@_copy_docstring_and_deprecators(Axes.set_yscale)
|
|
def yscale(value: str | ScaleBase, **kwargs) -> None:
|
|
...
|
|
|
|
def autumn() -> None:
|
|
"""
|
|
Set the colormap to 'autumn'.
|
|
|
|
This changes the default colormap as well as the colormap of the current
|
|
image if there is one. See ``help(colormaps)`` for more information.
|
|
"""
|
|
...
|
|
|
|
def bone() -> None:
|
|
"""
|
|
Set the colormap to 'bone'.
|
|
|
|
This changes the default colormap as well as the colormap of the current
|
|
image if there is one. See ``help(colormaps)`` for more information.
|
|
"""
|
|
...
|
|
|
|
def cool() -> None:
|
|
"""
|
|
Set the colormap to 'cool'.
|
|
|
|
This changes the default colormap as well as the colormap of the current
|
|
image if there is one. See ``help(colormaps)`` for more information.
|
|
"""
|
|
...
|
|
|
|
def copper() -> None:
|
|
"""
|
|
Set the colormap to 'copper'.
|
|
|
|
This changes the default colormap as well as the colormap of the current
|
|
image if there is one. See ``help(colormaps)`` for more information.
|
|
"""
|
|
...
|
|
|
|
def flag() -> None:
|
|
"""
|
|
Set the colormap to 'flag'.
|
|
|
|
This changes the default colormap as well as the colormap of the current
|
|
image if there is one. See ``help(colormaps)`` for more information.
|
|
"""
|
|
...
|
|
|
|
def gray() -> None:
|
|
"""
|
|
Set the colormap to 'gray'.
|
|
|
|
This changes the default colormap as well as the colormap of the current
|
|
image if there is one. See ``help(colormaps)`` for more information.
|
|
"""
|
|
...
|
|
|
|
def hot() -> None:
|
|
"""
|
|
Set the colormap to 'hot'.
|
|
|
|
This changes the default colormap as well as the colormap of the current
|
|
image if there is one. See ``help(colormaps)`` for more information.
|
|
"""
|
|
...
|
|
|
|
def hsv() -> None:
|
|
"""
|
|
Set the colormap to 'hsv'.
|
|
|
|
This changes the default colormap as well as the colormap of the current
|
|
image if there is one. See ``help(colormaps)`` for more information.
|
|
"""
|
|
...
|
|
|
|
def jet() -> None:
|
|
"""
|
|
Set the colormap to 'jet'.
|
|
|
|
This changes the default colormap as well as the colormap of the current
|
|
image if there is one. See ``help(colormaps)`` for more information.
|
|
"""
|
|
...
|
|
|
|
def pink() -> None:
|
|
"""
|
|
Set the colormap to 'pink'.
|
|
|
|
This changes the default colormap as well as the colormap of the current
|
|
image if there is one. See ``help(colormaps)`` for more information.
|
|
"""
|
|
...
|
|
|
|
def prism() -> None:
|
|
"""
|
|
Set the colormap to 'prism'.
|
|
|
|
This changes the default colormap as well as the colormap of the current
|
|
image if there is one. See ``help(colormaps)`` for more information.
|
|
"""
|
|
...
|
|
|
|
def spring() -> None:
|
|
"""
|
|
Set the colormap to 'spring'.
|
|
|
|
This changes the default colormap as well as the colormap of the current
|
|
image if there is one. See ``help(colormaps)`` for more information.
|
|
"""
|
|
...
|
|
|
|
def summer() -> None:
|
|
"""
|
|
Set the colormap to 'summer'.
|
|
|
|
This changes the default colormap as well as the colormap of the current
|
|
image if there is one. See ``help(colormaps)`` for more information.
|
|
"""
|
|
...
|
|
|
|
def winter() -> None:
|
|
"""
|
|
Set the colormap to 'winter'.
|
|
|
|
This changes the default colormap as well as the colormap of the current
|
|
image if there is one. See ``help(colormaps)`` for more information.
|
|
"""
|
|
...
|
|
|
|
def magma() -> None:
|
|
"""
|
|
Set the colormap to 'magma'.
|
|
|
|
This changes the default colormap as well as the colormap of the current
|
|
image if there is one. See ``help(colormaps)`` for more information.
|
|
"""
|
|
...
|
|
|
|
def inferno() -> None:
|
|
"""
|
|
Set the colormap to 'inferno'.
|
|
|
|
This changes the default colormap as well as the colormap of the current
|
|
image if there is one. See ``help(colormaps)`` for more information.
|
|
"""
|
|
...
|
|
|
|
def plasma() -> None:
|
|
"""
|
|
Set the colormap to 'plasma'.
|
|
|
|
This changes the default colormap as well as the colormap of the current
|
|
image if there is one. See ``help(colormaps)`` for more information.
|
|
"""
|
|
...
|
|
|
|
def viridis() -> None:
|
|
"""
|
|
Set the colormap to 'viridis'.
|
|
|
|
This changes the default colormap as well as the colormap of the current
|
|
image if there is one. See ``help(colormaps)`` for more information.
|
|
"""
|
|
...
|
|
|
|
def nipy_spectral() -> None:
|
|
"""
|
|
Set the colormap to 'nipy_spectral'.
|
|
|
|
This changes the default colormap as well as the colormap of the current
|
|
image if there is one. See ``help(colormaps)`` for more information.
|
|
"""
|
|
...
|
|
|