matplotlib-rs 0.0.8__cp315-cp315-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- docs/releases/0.0.1.md +268 -0
- docs/releases/0.0.2.md +69 -0
- docs/releases/0.0.3.md +80 -0
- docs/releases/0.0.4.md +73 -0
- docs/releases/0.0.5.md +24 -0
- docs/releases/0.0.6.md +24 -0
- docs/releases/0.0.7.md +24 -0
- docs/releases/0.0.8.md +16 -0
- licenses/LICENSE_CONTOURPY +29 -0
- licenses/LICENSE_CYCLER +27 -0
- licenses/LICENSE_DATEUTIL +54 -0
- licenses/LICENSE_KIWISOLVER +71 -0
- licenses/LICENSE_LIBWEBP +56 -0
- licenses/LICENSE_MATPLOTLIB +1253 -0
- licenses/LICENSE_PYPARSING +20 -0
- licenses/LICENSE_QHULL +39 -0
- licenses/LICENSE_SIX +18 -0
- matplotlib_rs/__init__.py +1683 -0
- matplotlib_rs/__main__.py +27 -0
- matplotlib_rs/_afm.py +500 -0
- matplotlib_rs/_animation_data.py +263 -0
- matplotlib_rs/_api/__init__.py +495 -0
- matplotlib_rs/_api/deprecation.py +534 -0
- matplotlib_rs/_axis_py.py +2991 -0
- matplotlib_rs/_blocking_input.py +31 -0
- matplotlib_rs/_cm.py +1500 -0
- matplotlib_rs/_cm_bivar.py +1289 -0
- matplotlib_rs/_cm_listed.py +2848 -0
- matplotlib_rs/_cm_multivar.py +167 -0
- matplotlib_rs/_color_data.py +1142 -0
- matplotlib_rs/_colormap.py +132 -0
- matplotlib_rs/_constrained_layout.py +825 -0
- matplotlib_rs/_contour.py +108 -0
- matplotlib_rs/_doc_cache.py +12214 -0
- matplotlib_rs/_docstring.py +142 -0
- matplotlib_rs/_enums.py +178 -0
- matplotlib_rs/_figure_rs.py +294 -0
- matplotlib_rs/_fontconfig_pattern.py +129 -0
- matplotlib_rs/_foreign.py +220 -0
- matplotlib_rs/_hook.py +94 -0
- matplotlib_rs/_image.py +160 -0
- matplotlib_rs/_imageio.py +229 -0
- matplotlib_rs/_internal_utils.py +65 -0
- matplotlib_rs/_kiwi.py +484 -0
- matplotlib_rs/_layoutgrid.py +549 -0
- matplotlib_rs/_live.py +192 -0
- matplotlib_rs/_mathtext.py +3103 -0
- matplotlib_rs/_mathtext_data.py +1811 -0
- matplotlib_rs/_mplrs.cp315-win_amd64.pyd +0 -0
- matplotlib_rs/_path.py +25 -0
- matplotlib_rs/_png.py +162 -0
- matplotlib_rs/_pylab_helpers.py +137 -0
- matplotlib_rs/_qhull.py +66 -0
- matplotlib_rs/_rcpush.py +84 -0
- matplotlib_rs/_spines_rs.py +108 -0
- matplotlib_rs/_style_helpers.py +52 -0
- matplotlib_rs/_text_helpers.py +51 -0
- matplotlib_rs/_tight_bbox.py +85 -0
- matplotlib_rs/_tight_layout.py +302 -0
- matplotlib_rs/_tri.py +140 -0
- matplotlib_rs/_type1font.py +1228 -0
- matplotlib_rs/_vendor/__init__.py +8 -0
- matplotlib_rs/_vendor/cycler.py +574 -0
- matplotlib_rs/_vendor/dateutil/__init__.py +27 -0
- matplotlib_rs/_vendor/dateutil/_common.py +44 -0
- matplotlib_rs/_vendor/dateutil/_tzdata_impl.py +148 -0
- matplotlib_rs/_vendor/dateutil/_version.py +5 -0
- matplotlib_rs/_vendor/dateutil/easter.py +90 -0
- matplotlib_rs/_vendor/dateutil/parser/__init__.py +62 -0
- matplotlib_rs/_vendor/dateutil/parser/_parser.py +1614 -0
- matplotlib_rs/_vendor/dateutil/parser/isoparser.py +417 -0
- matplotlib_rs/_vendor/dateutil/relativedelta.py +597 -0
- matplotlib_rs/_vendor/dateutil/rrule.py +1765 -0
- matplotlib_rs/_vendor/dateutil/tz/__init__.py +61 -0
- matplotlib_rs/_vendor/dateutil/tz/_common.py +420 -0
- matplotlib_rs/_vendor/dateutil/tz/_factories.py +81 -0
- matplotlib_rs/_vendor/dateutil/tz/_tzfile.py +1429 -0
- matplotlib_rs/_vendor/dateutil/tz/_tzpath.py +105 -0
- matplotlib_rs/_vendor/dateutil/tz/tz.py +1473 -0
- matplotlib_rs/_vendor/dateutil/tz/win.py +371 -0
- matplotlib_rs/_vendor/dateutil/tzwin.py +3 -0
- matplotlib_rs/_vendor/dateutil/utils.py +72 -0
- matplotlib_rs/_vendor/dateutil/zoneinfo/__init__.py +234 -0
- matplotlib_rs/_vendor/pyparsing/__init__.py +414 -0
- matplotlib_rs/_vendor/pyparsing/actions.py +265 -0
- matplotlib_rs/_vendor/pyparsing/common.py +571 -0
- matplotlib_rs/_vendor/pyparsing/core.py +6973 -0
- matplotlib_rs/_vendor/pyparsing/exceptions.py +354 -0
- matplotlib_rs/_vendor/pyparsing/helpers.py +1770 -0
- matplotlib_rs/_vendor/pyparsing/results.py +929 -0
- matplotlib_rs/_vendor/pyparsing/testing.py +399 -0
- matplotlib_rs/_vendor/pyparsing/unicode.py +357 -0
- matplotlib_rs/_vendor/pyparsing/util.py +515 -0
- matplotlib_rs/_vendor/pyparsing/warnings.py +11 -0
- matplotlib_rs/_vendor/six.py +1004 -0
- matplotlib_rs/animation.py +1843 -0
- matplotlib_rs/artist.py +2302 -0
- matplotlib_rs/axes/__init__.py +19 -0
- matplotlib_rs/axes/_axes.py +9402 -0
- matplotlib_rs/axes/_bar.py +185 -0
- matplotlib_rs/axes/_base.py +5236 -0
- matplotlib_rs/axes/_base_rs.py +727 -0
- matplotlib_rs/axes/_boxplot.py +391 -0
- matplotlib_rs/axes/_hist.py +99 -0
- matplotlib_rs/axes/_secondary_axes.py +357 -0
- matplotlib_rs/axis.py +1963 -0
- matplotlib_rs/backend_bases.py +3760 -0
- matplotlib_rs/backend_managers.py +388 -0
- matplotlib_rs/backend_tools.py +1002 -0
- matplotlib_rs/backends/__init__.py +6 -0
- matplotlib_rs/backends/_backend_pdf_ps.py +451 -0
- matplotlib_rs/backends/backend_agg.py +552 -0
- matplotlib_rs/backends/backend_mixed.py +123 -0
- matplotlib_rs/backends/backend_pdf.py +2711 -0
- matplotlib_rs/backends/backend_pgf.py +1031 -0
- matplotlib_rs/backends/backend_ps.py +1491 -0
- matplotlib_rs/backends/backend_svg.py +1395 -0
- matplotlib_rs/backends/backend_template.py +214 -0
- matplotlib_rs/backends/registry.py +423 -0
- matplotlib_rs/bezier.py +691 -0
- matplotlib_rs/category.py +236 -0
- matplotlib_rs/cbook.py +2762 -0
- matplotlib_rs/cm.py +251 -0
- matplotlib_rs/collections.py +2711 -0
- matplotlib_rs/colorbar.py +1586 -0
- matplotlib_rs/colorizer.py +909 -0
- matplotlib_rs/colors.py +4278 -0
- matplotlib_rs/container.py +256 -0
- matplotlib_rs/contour.py +1756 -0
- matplotlib_rs/dates.py +1847 -0
- matplotlib_rs/dviread.py +1386 -0
- matplotlib_rs/figure.py +3815 -0
- matplotlib_rs/font_manager.py +1855 -0
- matplotlib_rs/ft2font.py +515 -0
- matplotlib_rs/gridspec.py +808 -0
- matplotlib_rs/hatch.py +244 -0
- matplotlib_rs/image.py +1863 -0
- matplotlib_rs/inset.py +291 -0
- matplotlib_rs/layout_engine.py +310 -0
- matplotlib_rs/legend.py +1480 -0
- matplotlib_rs/legend_handler.py +812 -0
- matplotlib_rs/lines.py +1886 -0
- matplotlib_rs/markers.py +908 -0
- matplotlib_rs/mathtext.py +141 -0
- matplotlib_rs/mlab.py +959 -0
- matplotlib_rs/mpl-data/fonts/ttf/DejaVuSans-Bold.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/DejaVuSans-BoldOblique.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/DejaVuSans-Oblique.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/DejaVuSans.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/DejaVuSansDisplay.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/DejaVuSansMono-Bold.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/DejaVuSansMono-BoldOblique.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/DejaVuSansMono-Oblique.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/DejaVuSansMono.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/DejaVuSerif-Bold.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/DejaVuSerif-BoldItalic.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/DejaVuSerif-Italic.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/DejaVuSerif.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/DejaVuSerifDisplay.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/LICENSE_DEJAVU +99 -0
- matplotlib_rs/mpl-data/fonts/ttf/LICENSE_STIX +124 -0
- matplotlib_rs/mpl-data/fonts/ttf/LastResortHE-Regular.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/STIXGeneral.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/STIXGeneralBol.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/STIXGeneralBolIta.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/STIXGeneralItalic.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/STIXNonUni.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/STIXNonUniBol.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/STIXNonUniBolIta.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/STIXNonUniIta.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/STIXSizFiveSymReg.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/STIXSizFourSymBol.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/STIXSizFourSymReg.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/STIXSizOneSymBol.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/STIXSizOneSymReg.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/STIXSizThreeSymBol.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/STIXSizThreeSymReg.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/STIXSizTwoSymBol.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/STIXSizTwoSymReg.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/cmb10.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/cmex10.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/cmmi10.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/cmr10.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/cmss10.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/cmsy10.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/cmti10.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/cmtt10.ttf +0 -0
- matplotlib_rs/mpl-data/images/back-symbolic.svg +46 -0
- matplotlib_rs/mpl-data/images/back.pdf +0 -0
- matplotlib_rs/mpl-data/images/back.png +0 -0
- matplotlib_rs/mpl-data/images/back.svg +46 -0
- matplotlib_rs/mpl-data/images/back_large.png +0 -0
- matplotlib_rs/mpl-data/images/filesave-symbolic.svg +68 -0
- matplotlib_rs/mpl-data/images/filesave.pdf +72 -0
- matplotlib_rs/mpl-data/images/filesave.png +0 -0
- matplotlib_rs/mpl-data/images/filesave.svg +68 -0
- matplotlib_rs/mpl-data/images/filesave_large.png +0 -0
- matplotlib_rs/mpl-data/images/forward-symbolic.svg +46 -0
- matplotlib_rs/mpl-data/images/forward.pdf +0 -0
- matplotlib_rs/mpl-data/images/forward.png +0 -0
- matplotlib_rs/mpl-data/images/forward.svg +46 -0
- matplotlib_rs/mpl-data/images/forward_large.png +0 -0
- matplotlib_rs/mpl-data/images/hand.pdf +0 -0
- matplotlib_rs/mpl-data/images/hand.png +0 -0
- matplotlib_rs/mpl-data/images/hand.svg +130 -0
- matplotlib_rs/mpl-data/images/help-symbolic.svg +52 -0
- matplotlib_rs/mpl-data/images/help.pdf +71 -0
- matplotlib_rs/mpl-data/images/help.png +0 -0
- matplotlib_rs/mpl-data/images/help.svg +52 -0
- matplotlib_rs/mpl-data/images/help_large.png +0 -0
- matplotlib_rs/mpl-data/images/home-symbolic.svg +59 -0
- matplotlib_rs/mpl-data/images/home.pdf +0 -0
- matplotlib_rs/mpl-data/images/home.png +0 -0
- matplotlib_rs/mpl-data/images/home.svg +59 -0
- matplotlib_rs/mpl-data/images/home_large.png +0 -0
- matplotlib_rs/mpl-data/images/matplotlib.pdf +0 -0
- matplotlib_rs/mpl-data/images/matplotlib.png +0 -0
- matplotlib_rs/mpl-data/images/matplotlib.svg +3171 -0
- matplotlib_rs/mpl-data/images/matplotlib_large.png +0 -0
- matplotlib_rs/mpl-data/images/move-symbolic.svg +73 -0
- matplotlib_rs/mpl-data/images/move.pdf +0 -0
- matplotlib_rs/mpl-data/images/move.png +0 -0
- matplotlib_rs/mpl-data/images/move.svg +73 -0
- matplotlib_rs/mpl-data/images/move_large.png +0 -0
- matplotlib_rs/mpl-data/images/qt4_editor_options.pdf +0 -0
- matplotlib_rs/mpl-data/images/qt4_editor_options.png +0 -0
- matplotlib_rs/mpl-data/images/qt4_editor_options.svg +48 -0
- matplotlib_rs/mpl-data/images/qt4_editor_options_large.png +0 -0
- matplotlib_rs/mpl-data/images/subplots-symbolic.svg +81 -0
- matplotlib_rs/mpl-data/images/subplots.pdf +0 -0
- matplotlib_rs/mpl-data/images/subplots.png +0 -0
- matplotlib_rs/mpl-data/images/subplots.svg +81 -0
- matplotlib_rs/mpl-data/images/subplots_large.png +0 -0
- matplotlib_rs/mpl-data/images/zoom_to_rect-symbolic.svg +40 -0
- matplotlib_rs/mpl-data/images/zoom_to_rect.pdf +69 -0
- matplotlib_rs/mpl-data/images/zoom_to_rect.png +0 -0
- matplotlib_rs/mpl-data/images/zoom_to_rect.svg +40 -0
- matplotlib_rs/mpl-data/images/zoom_to_rect_large.png +0 -0
- matplotlib_rs/mpl-data/kpsewhich.lua +4 -0
- matplotlib_rs/mpl-data/matplotlibrc +849 -0
- matplotlib_rs/mpl-data/plot_directive/plot_directive.css +16 -0
- matplotlib_rs/mpl-data/sample_data/Minduka_Present_Blue_Pack.png +0 -0
- matplotlib_rs/mpl-data/sample_data/README.txt +2 -0
- matplotlib_rs/mpl-data/sample_data/Stocks.csv +526 -0
- matplotlib_rs/mpl-data/sample_data/axes_grid/bivariate_normal.npy +0 -0
- matplotlib_rs/mpl-data/sample_data/data_x_x2_x3.csv +11 -0
- matplotlib_rs/mpl-data/sample_data/eeg.dat +0 -0
- matplotlib_rs/mpl-data/sample_data/embedding_in_wx3.xrc +65 -0
- matplotlib_rs/mpl-data/sample_data/goog.npz +0 -0
- matplotlib_rs/mpl-data/sample_data/grace_hopper.jpg +0 -0
- matplotlib_rs/mpl-data/sample_data/jacksboro_fault_dem.npz +0 -0
- matplotlib_rs/mpl-data/sample_data/logo2.png +0 -0
- matplotlib_rs/mpl-data/sample_data/membrane.dat +0 -0
- matplotlib_rs/mpl-data/sample_data/msft.csv +66 -0
- matplotlib_rs/mpl-data/sample_data/s1045.ima.gz +0 -0
- matplotlib_rs/mpl-data/sample_data/topobathy.npz +0 -0
- matplotlib_rs/mpl-data/stylelib/Solarize_Light2.mplstyle +53 -0
- matplotlib_rs/mpl-data/stylelib/_classic_test_patch.mplstyle +8 -0
- matplotlib_rs/mpl-data/stylelib/_mpl-gallery-nogrid.mplstyle +19 -0
- matplotlib_rs/mpl-data/stylelib/_mpl-gallery.mplstyle +19 -0
- matplotlib_rs/mpl-data/stylelib/bmh.mplstyle +27 -0
- matplotlib_rs/mpl-data/stylelib/classic.mplstyle +491 -0
- matplotlib_rs/mpl-data/stylelib/dark_background.mplstyle +26 -0
- matplotlib_rs/mpl-data/stylelib/fast.mplstyle +11 -0
- matplotlib_rs/mpl-data/stylelib/fivethirtyeight.mplstyle +37 -0
- matplotlib_rs/mpl-data/stylelib/ggplot.mplstyle +39 -0
- matplotlib_rs/mpl-data/stylelib/grayscale.mplstyle +29 -0
- matplotlib_rs/mpl-data/stylelib/petroff10.mplstyle +5 -0
- matplotlib_rs/mpl-data/stylelib/petroff6.mplstyle +5 -0
- matplotlib_rs/mpl-data/stylelib/petroff8.mplstyle +5 -0
- matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-bright.mplstyle +3 -0
- matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-colorblind.mplstyle +3 -0
- matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-dark-palette.mplstyle +3 -0
- matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-dark.mplstyle +30 -0
- matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-darkgrid.mplstyle +30 -0
- matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-deep.mplstyle +3 -0
- matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-muted.mplstyle +3 -0
- matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-notebook.mplstyle +21 -0
- matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-paper.mplstyle +21 -0
- matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-pastel.mplstyle +3 -0
- matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-poster.mplstyle +21 -0
- matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-talk.mplstyle +21 -0
- matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-ticks.mplstyle +30 -0
- matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-white.mplstyle +30 -0
- matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-whitegrid.mplstyle +30 -0
- matplotlib_rs/mpl-data/stylelib/seaborn-v0_8.mplstyle +57 -0
- matplotlib_rs/mpl-data/stylelib/tableau-colorblind10.mplstyle +3 -0
- matplotlib_rs/mpl_toolkits/__init__.py +3 -0
- matplotlib_rs/mpl_toolkits/axes_grid1/__init__.py +11 -0
- matplotlib_rs/mpl_toolkits/axes_grid1/anchored_artists.py +415 -0
- matplotlib_rs/mpl_toolkits/axes_grid1/axes_divider.py +619 -0
- matplotlib_rs/mpl_toolkits/axes_grid1/axes_grid.py +565 -0
- matplotlib_rs/mpl_toolkits/axes_grid1/axes_rgb.py +158 -0
- matplotlib_rs/mpl_toolkits/axes_grid1/axes_size.py +272 -0
- matplotlib_rs/mpl_toolkits/axes_grid1/inset_locator.py +525 -0
- matplotlib_rs/mpl_toolkits/axes_grid1/mpl_axes.py +129 -0
- matplotlib_rs/mpl_toolkits/axes_grid1/parasite_axes.py +261 -0
- matplotlib_rs/mpl_toolkits/axisartist/__init__.py +15 -0
- matplotlib_rs/mpl_toolkits/axisartist/angle_helper.py +396 -0
- matplotlib_rs/mpl_toolkits/axisartist/axes_divider.py +3 -0
- matplotlib_rs/mpl_toolkits/axisartist/axis_artist.py +1148 -0
- matplotlib_rs/mpl_toolkits/axisartist/axisline_style.py +193 -0
- matplotlib_rs/mpl_toolkits/axisartist/axislines.py +475 -0
- matplotlib_rs/mpl_toolkits/axisartist/floating_axes.py +265 -0
- matplotlib_rs/mpl_toolkits/axisartist/grid_finder.py +329 -0
- matplotlib_rs/mpl_toolkits/axisartist/grid_helper_curvelinear.py +353 -0
- matplotlib_rs/mpl_toolkits/axisartist/parasite_axes.py +8 -0
- matplotlib_rs/mpl_toolkits/mplot3d/__init__.py +4 -0
- matplotlib_rs/mpl_toolkits/mplot3d/art3d.py +1758 -0
- matplotlib_rs/mpl_toolkits/mplot3d/axes3d.py +4462 -0
- matplotlib_rs/mpl_toolkits/mplot3d/axis3d.py +807 -0
- matplotlib_rs/mpl_toolkits/mplot3d/proj3d.py +270 -0
- matplotlib_rs/offsetbox.py +1726 -0
- matplotlib_rs/patches.py +5049 -0
- matplotlib_rs/path.py +1147 -0
- matplotlib_rs/patheffects.py +512 -0
- matplotlib_rs/projections/__init__.py +126 -0
- matplotlib_rs/projections/geo.py +512 -0
- matplotlib_rs/projections/polar.py +1518 -0
- matplotlib_rs/pylab.py +68 -0
- matplotlib_rs/pyplot.py +4834 -0
- matplotlib_rs/quiver.py +1236 -0
- matplotlib_rs/rcsetup.py +3435 -0
- matplotlib_rs/sankey.py +815 -0
- matplotlib_rs/scale.py +1002 -0
- matplotlib_rs/spines.py +618 -0
- matplotlib_rs/stackplot.py +144 -0
- matplotlib_rs/streamplot.py +768 -0
- matplotlib_rs/style/__init__.py +269 -0
- matplotlib_rs/style/core.py +28 -0
- matplotlib_rs/table.py +860 -0
- matplotlib_rs/texmanager.py +375 -0
- matplotlib_rs/text.py +2412 -0
- matplotlib_rs/textpath.py +377 -0
- matplotlib_rs/ticker.py +3111 -0
- matplotlib_rs/transforms.py +3069 -0
- matplotlib_rs/tri/__init__.py +24 -0
- matplotlib_rs/tri/_triangulation.py +248 -0
- matplotlib_rs/tri/_tricontour.py +271 -0
- matplotlib_rs/tri/_trifinder.py +97 -0
- matplotlib_rs/tri/_triinterpolate.py +1575 -0
- matplotlib_rs/tri/_tripcolor.py +170 -0
- matplotlib_rs/tri/_triplot.py +87 -0
- matplotlib_rs/tri/_trirefine.py +308 -0
- matplotlib_rs/tri/_tritools.py +264 -0
- matplotlib_rs/typing.py +597 -0
- matplotlib_rs/units.py +196 -0
- matplotlib_rs/widgets.py +4455 -0
- matplotlib_rs-0.0.8.dist-info/METADATA +392 -0
- matplotlib_rs-0.0.8.dist-info/RECORD +352 -0
- matplotlib_rs-0.0.8.dist-info/WHEEL +4 -0
- matplotlib_rs-0.0.8.dist-info/sboms/matplotlib-rs.cyclonedx.json +4390 -0
matplotlib_rs/pyplot.py
ADDED
|
@@ -0,0 +1,4834 @@
|
|
|
1
|
+
# Vendored from matplotlib 3.11 (see licenses/LICENSE_MATPLOTLIB), adapted for matplotlib_rs.
|
|
2
|
+
# Note: The first part of this file is hand-written and must be edited
|
|
3
|
+
# in-place. The second part, starting with
|
|
4
|
+
# ### REMAINING CONTENT GENERATED BY boilerplate.py ###
|
|
5
|
+
# is generated by the script boilerplate.py. It must not be edited here
|
|
6
|
+
# because all changes will be overwritten by the next run of the script.
|
|
7
|
+
# For more information see the description in boilerplate.py.
|
|
8
|
+
|
|
9
|
+
"""
|
|
10
|
+
`matplotlib.pyplot` is a state-based interface to matplotlib. It provides
|
|
11
|
+
an implicit, MATLAB-like, way of plotting. It also opens figures on your
|
|
12
|
+
screen, and acts as the figure GUI manager.
|
|
13
|
+
|
|
14
|
+
pyplot is mainly intended for interactive plots and simple cases of
|
|
15
|
+
programmatic plot generation::
|
|
16
|
+
|
|
17
|
+
import numpy as np
|
|
18
|
+
import matplotlib_rs.pyplot as plt
|
|
19
|
+
|
|
20
|
+
x = np.arange(0, 5, 0.1)
|
|
21
|
+
y = np.sin(x)
|
|
22
|
+
plt.plot(x, y)
|
|
23
|
+
plt.show()
|
|
24
|
+
|
|
25
|
+
The explicit object-oriented API is recommended for complex plots, though
|
|
26
|
+
pyplot is still usually used to create the figure and often the Axes in the
|
|
27
|
+
figure. See `.pyplot.figure`, `.pyplot.subplots`, and
|
|
28
|
+
`.pyplot.subplot_mosaic` to create figures, and
|
|
29
|
+
:doc:`Axes API </api/axes_api>` for the plotting methods on an Axes::
|
|
30
|
+
|
|
31
|
+
import numpy as np
|
|
32
|
+
import matplotlib_rs.pyplot as plt
|
|
33
|
+
|
|
34
|
+
x = np.arange(0, 5, 0.1)
|
|
35
|
+
y = np.sin(x)
|
|
36
|
+
fig, ax = plt.subplots()
|
|
37
|
+
ax.plot(x, y)
|
|
38
|
+
plt.show()
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
See :ref:`api_interfaces` for an explanation of the tradeoffs between the
|
|
42
|
+
implicit and explicit interfaces.
|
|
43
|
+
"""
|
|
44
|
+
|
|
45
|
+
# fmt: off
|
|
46
|
+
|
|
47
|
+
from __future__ import annotations
|
|
48
|
+
|
|
49
|
+
from contextlib import AbstractContextManager, ExitStack
|
|
50
|
+
from enum import Enum
|
|
51
|
+
import functools
|
|
52
|
+
import importlib
|
|
53
|
+
import inspect
|
|
54
|
+
import logging
|
|
55
|
+
import sys
|
|
56
|
+
import threading
|
|
57
|
+
import time
|
|
58
|
+
from typing import IO, TYPE_CHECKING, cast, overload
|
|
59
|
+
|
|
60
|
+
from matplotlib_rs.rcsetup import ccycler as cycler # noqa: F401, cycler.cycler
|
|
61
|
+
import matplotlib_rs as matplotlib
|
|
62
|
+
import matplotlib_rs.image; import matplotlib_rs as matplotlib
|
|
63
|
+
from matplotlib_rs import _api
|
|
64
|
+
# Re-exported (import x as x) for typing.
|
|
65
|
+
from matplotlib_rs import get_backend as get_backend, rcParams as rcParams
|
|
66
|
+
from matplotlib_rs import cm as cm # noqa: F401
|
|
67
|
+
from matplotlib_rs import style as style # noqa: F401
|
|
68
|
+
from matplotlib_rs import _pylab_helpers
|
|
69
|
+
from matplotlib_rs import interactive # noqa: F401
|
|
70
|
+
from matplotlib_rs import cbook
|
|
71
|
+
from matplotlib_rs import _docstring
|
|
72
|
+
from matplotlib_rs.backend_bases import (
|
|
73
|
+
FigureCanvasBase, FigureManagerBase, MouseButton)
|
|
74
|
+
from matplotlib_rs.figure import Figure, FigureBase, figaspect
|
|
75
|
+
from matplotlib_rs.gridspec import GridSpec, SubplotSpec
|
|
76
|
+
from matplotlib_rs import rcsetup, rcParamsDefault, rcParamsOrig
|
|
77
|
+
from matplotlib_rs.artist import Artist
|
|
78
|
+
from matplotlib_rs.axes import Axes
|
|
79
|
+
from matplotlib_rs.axes import Subplot # noqa: F401
|
|
80
|
+
from matplotlib_rs.backends import BackendFilter, backend_registry
|
|
81
|
+
from matplotlib_rs.colorizer import _ColorizerInterface, ColorizingArtist, Colorizer
|
|
82
|
+
from matplotlib_rs import mlab # for detrend_none, window_hanning
|
|
83
|
+
from matplotlib_rs.scale import get_scale_names # noqa: F401
|
|
84
|
+
|
|
85
|
+
from matplotlib_rs.cm import _colormaps
|
|
86
|
+
from matplotlib_rs.colors import _color_sequences, Colormap
|
|
87
|
+
|
|
88
|
+
import numpy as np
|
|
89
|
+
|
|
90
|
+
if TYPE_CHECKING:
|
|
91
|
+
from collections.abc import Callable, Hashable, Iterable, Sequence
|
|
92
|
+
import pathlib
|
|
93
|
+
import os
|
|
94
|
+
from typing import Any, BinaryIO, Literal, TypeVar
|
|
95
|
+
from typing_extensions import ParamSpec
|
|
96
|
+
|
|
97
|
+
import PIL.Image
|
|
98
|
+
from numpy.typing import ArrayLike
|
|
99
|
+
import pandas as pd
|
|
100
|
+
|
|
101
|
+
import matplotlib_rs.axes; import matplotlib_rs as matplotlib
|
|
102
|
+
import matplotlib_rs.artist; import matplotlib_rs as matplotlib
|
|
103
|
+
import matplotlib_rs.backend_bases; import matplotlib_rs as matplotlib
|
|
104
|
+
from matplotlib_rs.axis import Tick
|
|
105
|
+
from matplotlib_rs.axes._base import _AxesBase
|
|
106
|
+
from matplotlib_rs.backend_bases import (
|
|
107
|
+
CloseEvent,
|
|
108
|
+
DrawEvent,
|
|
109
|
+
KeyEvent,
|
|
110
|
+
MouseEvent,
|
|
111
|
+
PickEvent,
|
|
112
|
+
ResizeEvent,
|
|
113
|
+
)
|
|
114
|
+
from matplotlib_rs.cm import ScalarMappable
|
|
115
|
+
from matplotlib_rs.contour import ContourSet, QuadContourSet
|
|
116
|
+
from matplotlib_rs.collections import (
|
|
117
|
+
Collection,
|
|
118
|
+
FillBetweenPolyCollection,
|
|
119
|
+
LineCollection,
|
|
120
|
+
PolyCollection,
|
|
121
|
+
PathCollection,
|
|
122
|
+
EventCollection,
|
|
123
|
+
QuadMesh,
|
|
124
|
+
)
|
|
125
|
+
from matplotlib_rs.colorbar import Colorbar
|
|
126
|
+
from matplotlib_rs.container import (
|
|
127
|
+
BarContainer,
|
|
128
|
+
ErrorbarContainer,
|
|
129
|
+
PieContainer,
|
|
130
|
+
StemContainer,
|
|
131
|
+
)
|
|
132
|
+
from matplotlib_rs.figure import SubFigure
|
|
133
|
+
from matplotlib_rs.legend import Legend
|
|
134
|
+
from matplotlib_rs.mlab import GaussianKDE
|
|
135
|
+
from matplotlib_rs.image import AxesImage, FigureImage
|
|
136
|
+
from matplotlib_rs.patches import FancyArrow, StepPatch
|
|
137
|
+
from matplotlib_rs.quiver import Barbs, Quiver, QuiverKey
|
|
138
|
+
from matplotlib_rs.scale import ScaleBase
|
|
139
|
+
from matplotlib_rs.typing import (
|
|
140
|
+
CloseEventType,
|
|
141
|
+
ColorType,
|
|
142
|
+
CoordsType,
|
|
143
|
+
DataParamType,
|
|
144
|
+
DrawEventType,
|
|
145
|
+
HashableList,
|
|
146
|
+
KeyEventType,
|
|
147
|
+
LineStyleType,
|
|
148
|
+
MarkerType,
|
|
149
|
+
MouseEventType,
|
|
150
|
+
PickEventType,
|
|
151
|
+
RcGroupKeyType,
|
|
152
|
+
RcKeyType,
|
|
153
|
+
ResizeEventType,
|
|
154
|
+
LogLevel
|
|
155
|
+
)
|
|
156
|
+
from matplotlib_rs.widgets import SubplotTool
|
|
157
|
+
|
|
158
|
+
_P = ParamSpec('_P')
|
|
159
|
+
_R = TypeVar('_R')
|
|
160
|
+
_T = TypeVar('_T')
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
# We may not need the following imports here:
|
|
164
|
+
from matplotlib_rs.colors import Normalize
|
|
165
|
+
from matplotlib_rs.lines import Line2D, AxLine
|
|
166
|
+
from matplotlib_rs.text import Text, Annotation
|
|
167
|
+
from matplotlib_rs.patches import Arrow, Circle, Rectangle # noqa: F401
|
|
168
|
+
from matplotlib_rs.patches import Polygon
|
|
169
|
+
from matplotlib_rs.widgets import Button, Slider, Widget # noqa: F401
|
|
170
|
+
|
|
171
|
+
from .ticker import ( # noqa: F401
|
|
172
|
+
TickHelper, Formatter, FixedFormatter, NullFormatter, FuncFormatter,
|
|
173
|
+
FormatStrFormatter, ScalarFormatter, LogFormatter, LogFormatterExponent,
|
|
174
|
+
LogFormatterMathtext, Locator, IndexLocator, FixedLocator, NullLocator,
|
|
175
|
+
LinearLocator, LogLocator, AutoLocator, MultipleLocator, MaxNLocator)
|
|
176
|
+
|
|
177
|
+
_log = logging.getLogger(__name__)
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
# Explicit rename instead of import-as for typing's sake.
|
|
181
|
+
colormaps = _colormaps
|
|
182
|
+
color_sequences = _color_sequences
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
@overload
|
|
186
|
+
def _copy_docstring_and_deprecators(
|
|
187
|
+
method: Any,
|
|
188
|
+
func: Literal[None] = None
|
|
189
|
+
) -> Callable[[Callable[_P, _R]], Callable[_P, _R]]: ...
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
@overload
|
|
193
|
+
def _copy_docstring_and_deprecators(
|
|
194
|
+
method: Any, func: Callable[_P, _R]) -> Callable[_P, _R]: ...
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
def _copy_docstring_and_deprecators(
|
|
198
|
+
method: Any,
|
|
199
|
+
func: Callable[_P, _R] | None = None
|
|
200
|
+
) -> Callable[[Callable[_P, _R]], Callable[_P, _R]] | Callable[_P, _R]:
|
|
201
|
+
if func is None:
|
|
202
|
+
return cast('Callable[[Callable[_P, _R]], Callable[_P, _R]]',
|
|
203
|
+
functools.partial(_copy_docstring_and_deprecators, method))
|
|
204
|
+
decorators: list[Callable[[Callable[_P, _R]], Callable[_P, _R]]] = [
|
|
205
|
+
_docstring.copy(method)
|
|
206
|
+
]
|
|
207
|
+
# Check whether the definition of *method* includes @_api.rename_parameter
|
|
208
|
+
# or @_api.make_keyword_only decorators; if so, propagate them to the
|
|
209
|
+
# pyplot wrapper as well.
|
|
210
|
+
while hasattr(method, "__wrapped__"):
|
|
211
|
+
potential_decorator = _api.deprecation.DECORATORS.get(method)
|
|
212
|
+
if potential_decorator:
|
|
213
|
+
decorators.append(potential_decorator)
|
|
214
|
+
method = method.__wrapped__
|
|
215
|
+
for decorator in decorators[::-1]:
|
|
216
|
+
func = decorator(func)
|
|
217
|
+
_add_pyplot_note(func, method)
|
|
218
|
+
return func
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
_NO_PYPLOT_NOTE = [
|
|
222
|
+
'FigureBase._gci', # wrapped_func is private
|
|
223
|
+
'_AxesBase._sci', # wrapped_func is private
|
|
224
|
+
'Artist.findobj', # not a standard pyplot wrapper because it does not operate
|
|
225
|
+
# on the current Figure / Axes. Explanation of relation would
|
|
226
|
+
# be more complex and is not too important.
|
|
227
|
+
]
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
def _add_pyplot_note(func, wrapped_func):
|
|
231
|
+
"""
|
|
232
|
+
Add a note to the docstring of *func* that it is a pyplot wrapper.
|
|
233
|
+
|
|
234
|
+
The note is added to the "Notes" section of the docstring. If that does
|
|
235
|
+
not exist, a "Notes" section is created. In numpydoc, the "Notes"
|
|
236
|
+
section is the third last possible section, only potentially followed by
|
|
237
|
+
"References" and "Examples".
|
|
238
|
+
"""
|
|
239
|
+
if not func.__doc__:
|
|
240
|
+
return # nothing to do
|
|
241
|
+
|
|
242
|
+
qualname = wrapped_func.__qualname__
|
|
243
|
+
if qualname in _NO_PYPLOT_NOTE:
|
|
244
|
+
return
|
|
245
|
+
|
|
246
|
+
wrapped_func_is_method = True
|
|
247
|
+
if "." not in qualname:
|
|
248
|
+
# method qualnames are prefixed by the class and ".", e.g. "Axes.plot"
|
|
249
|
+
wrapped_func_is_method = False
|
|
250
|
+
link = f"{wrapped_func.__module__}.{qualname}"
|
|
251
|
+
elif qualname.startswith("Axes."): # e.g. "Axes.plot"
|
|
252
|
+
link = ".axes." + qualname
|
|
253
|
+
elif qualname.startswith("_AxesBase."): # e.g. "_AxesBase.set_xlabel"
|
|
254
|
+
link = ".axes.Axes" + qualname[9:]
|
|
255
|
+
elif qualname.startswith("Figure."): # e.g. "Figure.figimage"
|
|
256
|
+
link = "." + qualname
|
|
257
|
+
elif qualname.startswith("FigureBase."): # e.g. "FigureBase.gca"
|
|
258
|
+
link = ".Figure" + qualname[10:]
|
|
259
|
+
elif qualname.startswith("FigureCanvasBase."): # "FigureBaseCanvas.mpl_connect"
|
|
260
|
+
link = "." + qualname
|
|
261
|
+
else:
|
|
262
|
+
raise RuntimeError(f"Wrapped method from unexpected class: {qualname}")
|
|
263
|
+
|
|
264
|
+
if wrapped_func_is_method:
|
|
265
|
+
message = f"This is the :ref:`pyplot wrapper <pyplot_interface>` for `{link}`."
|
|
266
|
+
else:
|
|
267
|
+
message = f"This is equivalent to `{link}`."
|
|
268
|
+
|
|
269
|
+
# Find the correct insert position:
|
|
270
|
+
# - either we already have a "Notes" section into which we can insert
|
|
271
|
+
# - or we create one before the next present section. Note that in numpydoc, the
|
|
272
|
+
# "Notes" section is the third last possible section, only potentially followed
|
|
273
|
+
# by "References" and "Examples".
|
|
274
|
+
# - or we append a new "Notes" section at the end.
|
|
275
|
+
doc = inspect.cleandoc(func.__doc__)
|
|
276
|
+
if "\nNotes\n-----" in doc:
|
|
277
|
+
before, after = doc.split("\nNotes\n-----", 1)
|
|
278
|
+
elif (index := doc.find("\nReferences\n----------")) != -1:
|
|
279
|
+
before, after = doc[:index], doc[index:]
|
|
280
|
+
elif (index := doc.find("\nExamples\n--------")) != -1:
|
|
281
|
+
before, after = doc[:index], doc[index:]
|
|
282
|
+
else:
|
|
283
|
+
# No "Notes", "References", or "Examples" --> append to the end.
|
|
284
|
+
before = doc + "\n"
|
|
285
|
+
after = ""
|
|
286
|
+
|
|
287
|
+
func.__doc__ = f"{before}\nNotes\n-----\n\n.. note::\n\n {message}\n{after}"
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
## Global ##
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
# The state controlled by {,un}install_repl_displayhook().
|
|
294
|
+
_ReplDisplayHook = Enum("_ReplDisplayHook", ["NONE", "PLAIN", "IPYTHON"])
|
|
295
|
+
_REPL_DISPLAYHOOK = _ReplDisplayHook.NONE
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
def _draw_all_if_interactive() -> None:
|
|
299
|
+
if matplotlib.is_interactive():
|
|
300
|
+
draw_all()
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
def install_repl_displayhook() -> None:
|
|
304
|
+
"""
|
|
305
|
+
Connect to the display hook of the current shell.
|
|
306
|
+
|
|
307
|
+
The display hook gets called when the read-evaluate-print-loop (REPL) of
|
|
308
|
+
the shell has finished the execution of a command. We use this callback
|
|
309
|
+
to be able to automatically update a figure in interactive mode.
|
|
310
|
+
|
|
311
|
+
This works both with IPython and with vanilla python shells.
|
|
312
|
+
"""
|
|
313
|
+
global _REPL_DISPLAYHOOK
|
|
314
|
+
|
|
315
|
+
if _REPL_DISPLAYHOOK is _ReplDisplayHook.IPYTHON:
|
|
316
|
+
return
|
|
317
|
+
|
|
318
|
+
# See if we have IPython hooks around, if so use them.
|
|
319
|
+
# Use ``sys.modules.get(name)`` rather than ``name in sys.modules`` as
|
|
320
|
+
# entries can also have been explicitly set to None.
|
|
321
|
+
mod_ipython = sys.modules.get("IPython")
|
|
322
|
+
if not mod_ipython:
|
|
323
|
+
_REPL_DISPLAYHOOK = _ReplDisplayHook.PLAIN
|
|
324
|
+
return
|
|
325
|
+
ip = mod_ipython.get_ipython()
|
|
326
|
+
if not ip:
|
|
327
|
+
_REPL_DISPLAYHOOK = _ReplDisplayHook.PLAIN
|
|
328
|
+
return
|
|
329
|
+
|
|
330
|
+
ip.events.register("post_execute", _draw_all_if_interactive)
|
|
331
|
+
_REPL_DISPLAYHOOK = _ReplDisplayHook.IPYTHON
|
|
332
|
+
|
|
333
|
+
if mod_ipython.version_info[:2] < (8, 24):
|
|
334
|
+
# Use of backend2gui is not needed for IPython >= 8.24 as that functionality
|
|
335
|
+
# has been moved to Matplotlib.
|
|
336
|
+
# This code can be removed when Python 3.12, the latest version supported by
|
|
337
|
+
# IPython < 8.24, reaches end-of-life in late 2028.
|
|
338
|
+
from IPython.core.pylabtools import backend2gui
|
|
339
|
+
ipython_gui_name = backend2gui.get(get_backend())
|
|
340
|
+
else:
|
|
341
|
+
_, ipython_gui_name = backend_registry.resolve_backend(get_backend())
|
|
342
|
+
# trigger IPython's eventloop integration, if available
|
|
343
|
+
if ipython_gui_name:
|
|
344
|
+
ip.enable_gui(ipython_gui_name)
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
def uninstall_repl_displayhook() -> None:
|
|
348
|
+
"""Disconnect from the display hook of the current shell."""
|
|
349
|
+
global _REPL_DISPLAYHOOK
|
|
350
|
+
if _REPL_DISPLAYHOOK is _ReplDisplayHook.IPYTHON:
|
|
351
|
+
from IPython import get_ipython
|
|
352
|
+
ip = get_ipython()
|
|
353
|
+
ip.events.unregister("post_execute", _draw_all_if_interactive)
|
|
354
|
+
_REPL_DISPLAYHOOK = _ReplDisplayHook.NONE
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
draw_all = _pylab_helpers.Gcf.draw_all
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
# Ensure this appears in the pyplot docs.
|
|
361
|
+
@_copy_docstring_and_deprecators(matplotlib.set_loglevel)
|
|
362
|
+
def set_loglevel(level: LogLevel) -> None:
|
|
363
|
+
return matplotlib.set_loglevel(level)
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
@_copy_docstring_and_deprecators(Artist.findobj)
|
|
367
|
+
def findobj(
|
|
368
|
+
o: Artist | None = None,
|
|
369
|
+
match: Callable[[Artist], bool] | type[Artist] | None = None,
|
|
370
|
+
include_self: bool = True
|
|
371
|
+
) -> list[Artist]:
|
|
372
|
+
if o is None:
|
|
373
|
+
o = gcf()
|
|
374
|
+
return o.findobj(match, include_self=include_self)
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
_backend_mod: type[matplotlib.backend_bases._Backend] | None = None
|
|
378
|
+
|
|
379
|
+
|
|
380
|
+
def _get_backend_mod() -> type[matplotlib.backend_bases._Backend]:
|
|
381
|
+
"""
|
|
382
|
+
Ensure that a backend is selected and return it.
|
|
383
|
+
|
|
384
|
+
This is currently private, but may be made public in the future.
|
|
385
|
+
"""
|
|
386
|
+
if _backend_mod is None:
|
|
387
|
+
# Use rcParams._get("backend") to avoid going through the fallback
|
|
388
|
+
# logic (which will (re)import pyplot and then call switch_backend if
|
|
389
|
+
# we need to resolve the auto sentinel)
|
|
390
|
+
switch_backend(rcParams._get("backend"))
|
|
391
|
+
return cast(type[matplotlib.backend_bases._Backend], _backend_mod)
|
|
392
|
+
|
|
393
|
+
|
|
394
|
+
def switch_backend(newbackend: str) -> None:
|
|
395
|
+
"""
|
|
396
|
+
Set the pyplot backend.
|
|
397
|
+
|
|
398
|
+
Switching to an interactive backend is possible only if no event loop for
|
|
399
|
+
another interactive backend has started. Switching to and from
|
|
400
|
+
non-interactive backends is always possible.
|
|
401
|
+
|
|
402
|
+
Parameters
|
|
403
|
+
----------
|
|
404
|
+
newbackend : str
|
|
405
|
+
The case-insensitive name of the backend to use.
|
|
406
|
+
|
|
407
|
+
"""
|
|
408
|
+
global _backend_mod
|
|
409
|
+
# make sure the init is pulled up so we can assign to it later
|
|
410
|
+
import matplotlib_rs.backends; import matplotlib_rs as matplotlib
|
|
411
|
+
|
|
412
|
+
if newbackend is rcsetup._auto_backend_sentinel:
|
|
413
|
+
current_framework = cbook._get_running_interactive_framework()
|
|
414
|
+
|
|
415
|
+
if (current_framework and
|
|
416
|
+
(backend := backend_registry.backend_for_gui_framework(
|
|
417
|
+
current_framework))):
|
|
418
|
+
candidates = [backend]
|
|
419
|
+
else:
|
|
420
|
+
candidates = []
|
|
421
|
+
candidates += [
|
|
422
|
+
"macosx", "qtagg", "gtk4agg", "gtk3agg", "tkagg", "wxagg"]
|
|
423
|
+
|
|
424
|
+
# Don't try to fallback on the cairo-based backends as they each have
|
|
425
|
+
# an additional dependency (pycairo) over the agg-based backend, and
|
|
426
|
+
# are of worse quality.
|
|
427
|
+
for candidate in candidates:
|
|
428
|
+
try:
|
|
429
|
+
switch_backend(candidate)
|
|
430
|
+
except ImportError:
|
|
431
|
+
_log.debug("Skipping backend candidate %r as loading failed.",
|
|
432
|
+
candidate, exc_info=True)
|
|
433
|
+
continue
|
|
434
|
+
else:
|
|
435
|
+
rcParamsOrig['backend'] = candidate
|
|
436
|
+
return
|
|
437
|
+
else:
|
|
438
|
+
# Switching to Agg should always succeed; if it doesn't, let the
|
|
439
|
+
# exception propagate out.
|
|
440
|
+
switch_backend("agg")
|
|
441
|
+
rcParamsOrig["backend"] = "agg"
|
|
442
|
+
return
|
|
443
|
+
old_backend = rcParams._get('backend') # get without triggering backend resolution
|
|
444
|
+
|
|
445
|
+
module = backend_registry.load_backend_module(newbackend)
|
|
446
|
+
canvas_class = module.FigureCanvas
|
|
447
|
+
|
|
448
|
+
required_framework = canvas_class.required_interactive_framework
|
|
449
|
+
if required_framework is not None:
|
|
450
|
+
current_framework = cbook._get_running_interactive_framework()
|
|
451
|
+
if (current_framework and required_framework
|
|
452
|
+
and current_framework != required_framework):
|
|
453
|
+
raise ImportError(
|
|
454
|
+
"Cannot load backend {!r} which requires the {!r} interactive "
|
|
455
|
+
"framework, as {!r} is currently running".format(
|
|
456
|
+
newbackend, required_framework, current_framework))
|
|
457
|
+
|
|
458
|
+
# Load the new_figure_manager() and show() functions from the backend.
|
|
459
|
+
|
|
460
|
+
# Classically, backends can directly export these functions. This should
|
|
461
|
+
# keep working for backcompat.
|
|
462
|
+
new_figure_manager = getattr(module, "new_figure_manager", None)
|
|
463
|
+
show = getattr(module, "show", None)
|
|
464
|
+
|
|
465
|
+
# In that classical approach, backends are implemented as modules, but
|
|
466
|
+
# "inherit" default method implementations from backend_bases._Backend.
|
|
467
|
+
# This is achieved by creating a "class" that inherits from
|
|
468
|
+
# backend_bases._Backend and whose body is filled with the module globals.
|
|
469
|
+
class backend_mod(matplotlib.backend_bases._Backend):
|
|
470
|
+
locals().update(vars(module))
|
|
471
|
+
|
|
472
|
+
# However, the newer approach for defining new_figure_manager and
|
|
473
|
+
# show is to derive them from canvas methods. In that case, also
|
|
474
|
+
# update backend_mod accordingly; also, per-backend customization of
|
|
475
|
+
# draw_if_interactive is disabled.
|
|
476
|
+
if new_figure_manager is None:
|
|
477
|
+
|
|
478
|
+
def new_figure_manager_given_figure(num, figure):
|
|
479
|
+
return canvas_class.new_manager(figure, num)
|
|
480
|
+
|
|
481
|
+
def new_figure_manager(num, *args, FigureClass=Figure, **kwargs):
|
|
482
|
+
fig = FigureClass(*args, **kwargs)
|
|
483
|
+
return new_figure_manager_given_figure(num, fig)
|
|
484
|
+
|
|
485
|
+
def draw_if_interactive() -> None:
|
|
486
|
+
if matplotlib.is_interactive():
|
|
487
|
+
manager = _pylab_helpers.Gcf.get_active()
|
|
488
|
+
if manager:
|
|
489
|
+
manager.canvas.draw_idle()
|
|
490
|
+
|
|
491
|
+
backend_mod.new_figure_manager_given_figure = ( # type: ignore[method-assign]
|
|
492
|
+
new_figure_manager_given_figure)
|
|
493
|
+
backend_mod.new_figure_manager = ( # type: ignore[method-assign]
|
|
494
|
+
new_figure_manager)
|
|
495
|
+
backend_mod.draw_if_interactive = ( # type: ignore[method-assign]
|
|
496
|
+
draw_if_interactive)
|
|
497
|
+
|
|
498
|
+
# If the manager explicitly overrides pyplot_show, use it even if a global
|
|
499
|
+
# show is already present, as the latter may be here for backcompat.
|
|
500
|
+
manager_class = getattr(canvas_class, "manager_class", None)
|
|
501
|
+
# We can't compare directly manager_class.pyplot_show and FMB.pyplot_show because
|
|
502
|
+
# pyplot_show is a classmethod so the above constructs are bound classmethods, and
|
|
503
|
+
# thus always different (being bound to different classes). We also have to use
|
|
504
|
+
# getattr_static instead of vars as manager_class could have no __dict__.
|
|
505
|
+
manager_pyplot_show = inspect.getattr_static(manager_class, "pyplot_show", None)
|
|
506
|
+
base_pyplot_show = inspect.getattr_static(FigureManagerBase, "pyplot_show", None)
|
|
507
|
+
if (show is None
|
|
508
|
+
or (manager_pyplot_show is not None
|
|
509
|
+
and manager_pyplot_show != base_pyplot_show)):
|
|
510
|
+
if not manager_pyplot_show:
|
|
511
|
+
raise ValueError(
|
|
512
|
+
f"Backend {newbackend} defines neither FigureCanvas.manager_class nor "
|
|
513
|
+
f"a toplevel show function")
|
|
514
|
+
_pyplot_show = cast('Any', manager_class).pyplot_show
|
|
515
|
+
backend_mod.show = _pyplot_show # type: ignore[method-assign]
|
|
516
|
+
|
|
517
|
+
_log.debug("Loaded backend %s version %s.",
|
|
518
|
+
newbackend, backend_mod.backend_version)
|
|
519
|
+
|
|
520
|
+
if newbackend in ("ipympl", "widget"):
|
|
521
|
+
# ipympl < 0.9.4 expects rcParams["backend"] to be the fully-qualified backend
|
|
522
|
+
# name "module://ipympl.backend_nbagg" not short names "ipympl" or "widget".
|
|
523
|
+
import importlib.metadata as im
|
|
524
|
+
from matplotlib_rs import _parse_to_version_info # type: ignore[attr-defined]
|
|
525
|
+
try:
|
|
526
|
+
module_version = im.version("ipympl")
|
|
527
|
+
if _parse_to_version_info(module_version) < (0, 9, 4):
|
|
528
|
+
newbackend = "module://ipympl.backend_nbagg"
|
|
529
|
+
except im.PackageNotFoundError:
|
|
530
|
+
pass
|
|
531
|
+
|
|
532
|
+
rcParams['backend'] = rcParamsDefault['backend'] = newbackend
|
|
533
|
+
_backend_mod = backend_mod
|
|
534
|
+
for func_name in ["new_figure_manager", "draw_if_interactive", "show"]:
|
|
535
|
+
globals()[func_name].__signature__ = inspect.signature(
|
|
536
|
+
getattr(backend_mod, func_name))
|
|
537
|
+
|
|
538
|
+
# Need to keep a global reference to the backend for compatibility reasons.
|
|
539
|
+
# See https://github.com/matplotlib/matplotlib/issues/6092
|
|
540
|
+
matplotlib.backends.backend = newbackend # type: ignore[attr-defined]
|
|
541
|
+
|
|
542
|
+
# Make sure the repl display hook is installed in case we become interactive.
|
|
543
|
+
try:
|
|
544
|
+
install_repl_displayhook()
|
|
545
|
+
except NotImplementedError as err:
|
|
546
|
+
_log.warning("Fallback to a different backend")
|
|
547
|
+
raise ImportError from err
|
|
548
|
+
|
|
549
|
+
|
|
550
|
+
def _warn_if_gui_out_of_main_thread() -> None:
|
|
551
|
+
warn = False
|
|
552
|
+
canvas_class = cast(type[FigureCanvasBase], _get_backend_mod().FigureCanvas)
|
|
553
|
+
if canvas_class.required_interactive_framework:
|
|
554
|
+
if hasattr(threading, 'get_native_id'):
|
|
555
|
+
# This compares native thread ids because even if Python-level
|
|
556
|
+
# Thread objects match, the underlying OS thread (which is what
|
|
557
|
+
# really matters) may be different on Python implementations with
|
|
558
|
+
# green threads.
|
|
559
|
+
if threading.get_native_id() != threading.main_thread().native_id:
|
|
560
|
+
warn = True
|
|
561
|
+
else:
|
|
562
|
+
# Fall back to Python-level Thread if native IDs are unavailable,
|
|
563
|
+
# mainly for PyPy.
|
|
564
|
+
if threading.current_thread() is not threading.main_thread():
|
|
565
|
+
warn = True
|
|
566
|
+
if warn:
|
|
567
|
+
_api.warn_external(
|
|
568
|
+
"Starting a Matplotlib GUI outside of the main thread will likely "
|
|
569
|
+
"fail.")
|
|
570
|
+
|
|
571
|
+
|
|
572
|
+
# This function's signature is rewritten upon backend-load by switch_backend.
|
|
573
|
+
def new_figure_manager(*args, **kwargs):
|
|
574
|
+
"""Create a new figure manager instance."""
|
|
575
|
+
_warn_if_gui_out_of_main_thread()
|
|
576
|
+
return _get_backend_mod().new_figure_manager(*args, **kwargs)
|
|
577
|
+
|
|
578
|
+
|
|
579
|
+
# This function's signature is rewritten upon backend-load by switch_backend.
|
|
580
|
+
def draw_if_interactive(*args, **kwargs):
|
|
581
|
+
"""
|
|
582
|
+
Redraw the current figure if in interactive mode.
|
|
583
|
+
|
|
584
|
+
.. warning::
|
|
585
|
+
|
|
586
|
+
End users will typically not have to call this function because the
|
|
587
|
+
the interactive mode takes care of this.
|
|
588
|
+
"""
|
|
589
|
+
return _get_backend_mod().draw_if_interactive(*args, **kwargs)
|
|
590
|
+
|
|
591
|
+
|
|
592
|
+
@overload
|
|
593
|
+
def show(*, block: bool, **kwargs) -> None: ...
|
|
594
|
+
|
|
595
|
+
|
|
596
|
+
@overload
|
|
597
|
+
def show(*args: Any, **kwargs: Any) -> None: ...
|
|
598
|
+
|
|
599
|
+
|
|
600
|
+
# This function's signature is rewritten upon backend-load by switch_backend.
|
|
601
|
+
def show(*args, **kwargs) -> None:
|
|
602
|
+
"""
|
|
603
|
+
Display all open figures.
|
|
604
|
+
|
|
605
|
+
Parameters
|
|
606
|
+
----------
|
|
607
|
+
block : bool, optional
|
|
608
|
+
Whether to wait for all figures to be closed before returning.
|
|
609
|
+
|
|
610
|
+
If `True` block and run the GUI main loop until all figure windows
|
|
611
|
+
are closed.
|
|
612
|
+
|
|
613
|
+
If `False` ensure that all figure windows are displayed and return
|
|
614
|
+
immediately. In this case, you are responsible for ensuring
|
|
615
|
+
that the event loop is running to have responsive figures.
|
|
616
|
+
|
|
617
|
+
Defaults to True in non-interactive mode and to False in interactive
|
|
618
|
+
mode (see `.pyplot.isinteractive`).
|
|
619
|
+
|
|
620
|
+
See Also
|
|
621
|
+
--------
|
|
622
|
+
ion : Enable interactive mode, which shows / updates the figure after
|
|
623
|
+
every plotting command, so that calling ``show()`` is not necessary.
|
|
624
|
+
ioff : Disable interactive mode.
|
|
625
|
+
savefig : Save the figure to an image file instead of showing it on screen.
|
|
626
|
+
|
|
627
|
+
Notes
|
|
628
|
+
-----
|
|
629
|
+
**Saving figures to file and showing a window at the same time**
|
|
630
|
+
|
|
631
|
+
If you want an image file as well as a user interface window, use
|
|
632
|
+
`.pyplot.savefig` before `.pyplot.show`. At the end of (a blocking)
|
|
633
|
+
``show()`` the figure is closed and thus unregistered from pyplot. Calling
|
|
634
|
+
`.pyplot.savefig` afterwards would save a new and thus empty figure. This
|
|
635
|
+
limitation of command order does not apply if the show is non-blocking or
|
|
636
|
+
if you keep a reference to the figure and use `.Figure.savefig`.
|
|
637
|
+
|
|
638
|
+
**Auto-show in jupyter notebooks**
|
|
639
|
+
|
|
640
|
+
The jupyter backends (activated via ``%matplotlib inline``,
|
|
641
|
+
``%matplotlib notebook``, or ``%matplotlib widget``), call ``show()`` at
|
|
642
|
+
the end of every cell by default. Thus, you usually don't have to call it
|
|
643
|
+
explicitly there.
|
|
644
|
+
"""
|
|
645
|
+
_warn_if_gui_out_of_main_thread()
|
|
646
|
+
return _get_backend_mod().show(*args, **kwargs)
|
|
647
|
+
|
|
648
|
+
|
|
649
|
+
def isinteractive() -> bool:
|
|
650
|
+
"""
|
|
651
|
+
Return whether plots are updated after every plotting command.
|
|
652
|
+
|
|
653
|
+
The interactive mode is mainly useful if you build plots from the command
|
|
654
|
+
line and want to see the effect of each command while you are building the
|
|
655
|
+
figure.
|
|
656
|
+
|
|
657
|
+
In interactive mode:
|
|
658
|
+
|
|
659
|
+
- newly created figures will be shown immediately;
|
|
660
|
+
- figures will automatically redraw on change;
|
|
661
|
+
- `.pyplot.show` will not block by default.
|
|
662
|
+
|
|
663
|
+
In non-interactive mode:
|
|
664
|
+
|
|
665
|
+
- newly created figures and changes to figures will not be reflected until
|
|
666
|
+
explicitly asked to be;
|
|
667
|
+
- `.pyplot.show` will block by default.
|
|
668
|
+
|
|
669
|
+
See Also
|
|
670
|
+
--------
|
|
671
|
+
ion : Enable interactive mode.
|
|
672
|
+
ioff : Disable interactive mode.
|
|
673
|
+
show : Show all figures (and maybe block).
|
|
674
|
+
pause : Show all figures, and block for a time.
|
|
675
|
+
"""
|
|
676
|
+
return matplotlib.is_interactive()
|
|
677
|
+
|
|
678
|
+
|
|
679
|
+
# Note: The return type of ioff being AbstractContextManager
|
|
680
|
+
# instead of ExitStack is deliberate.
|
|
681
|
+
# See https://github.com/matplotlib/matplotlib/issues/27659
|
|
682
|
+
# and https://github.com/matplotlib/matplotlib/pull/27667 for more info.
|
|
683
|
+
def ioff() -> AbstractContextManager:
|
|
684
|
+
"""
|
|
685
|
+
Disable interactive mode.
|
|
686
|
+
|
|
687
|
+
See `.pyplot.isinteractive` for more details.
|
|
688
|
+
|
|
689
|
+
See Also
|
|
690
|
+
--------
|
|
691
|
+
ion : Enable interactive mode.
|
|
692
|
+
isinteractive : Whether interactive mode is enabled.
|
|
693
|
+
show : Show all figures (and maybe block).
|
|
694
|
+
pause : Show all figures, and block for a time.
|
|
695
|
+
|
|
696
|
+
Notes
|
|
697
|
+
-----
|
|
698
|
+
For a temporary change, this can be used as a context manager::
|
|
699
|
+
|
|
700
|
+
# if interactive mode is on
|
|
701
|
+
# then figures will be shown on creation
|
|
702
|
+
plt.ion()
|
|
703
|
+
# This figure will be shown immediately
|
|
704
|
+
fig = plt.figure()
|
|
705
|
+
|
|
706
|
+
with plt.ioff():
|
|
707
|
+
# interactive mode will be off
|
|
708
|
+
# figures will not automatically be shown
|
|
709
|
+
fig2 = plt.figure()
|
|
710
|
+
# ...
|
|
711
|
+
|
|
712
|
+
To enable optional usage as a context manager, this function returns a
|
|
713
|
+
context manager object, which is not intended to be stored or
|
|
714
|
+
accessed by the user.
|
|
715
|
+
"""
|
|
716
|
+
stack = ExitStack()
|
|
717
|
+
stack.callback(ion if isinteractive() else ioff)
|
|
718
|
+
matplotlib.interactive(False)
|
|
719
|
+
uninstall_repl_displayhook()
|
|
720
|
+
return stack
|
|
721
|
+
|
|
722
|
+
|
|
723
|
+
# Note: The return type of ion being AbstractContextManager
|
|
724
|
+
# instead of ExitStack is deliberate.
|
|
725
|
+
# See https://github.com/matplotlib/matplotlib/issues/27659
|
|
726
|
+
# and https://github.com/matplotlib/matplotlib/pull/27667 for more info.
|
|
727
|
+
def ion() -> AbstractContextManager:
|
|
728
|
+
"""
|
|
729
|
+
Enable interactive mode.
|
|
730
|
+
|
|
731
|
+
See `.pyplot.isinteractive` for more details.
|
|
732
|
+
|
|
733
|
+
See Also
|
|
734
|
+
--------
|
|
735
|
+
ioff : Disable interactive mode.
|
|
736
|
+
isinteractive : Whether interactive mode is enabled.
|
|
737
|
+
show : Show all figures (and maybe block).
|
|
738
|
+
pause : Show all figures, and block for a time.
|
|
739
|
+
|
|
740
|
+
Notes
|
|
741
|
+
-----
|
|
742
|
+
For a temporary change, this can be used as a context manager::
|
|
743
|
+
|
|
744
|
+
# if interactive mode is off
|
|
745
|
+
# then figures will not be shown on creation
|
|
746
|
+
plt.ioff()
|
|
747
|
+
# This figure will not be shown immediately
|
|
748
|
+
fig = plt.figure()
|
|
749
|
+
|
|
750
|
+
with plt.ion():
|
|
751
|
+
# interactive mode will be on
|
|
752
|
+
# figures will automatically be shown
|
|
753
|
+
fig2 = plt.figure()
|
|
754
|
+
# ...
|
|
755
|
+
|
|
756
|
+
To enable optional usage as a context manager, this function returns a
|
|
757
|
+
context manager object, which is not intended to be stored or
|
|
758
|
+
accessed by the user.
|
|
759
|
+
"""
|
|
760
|
+
stack = ExitStack()
|
|
761
|
+
stack.callback(ion if isinteractive() else ioff)
|
|
762
|
+
matplotlib.interactive(True)
|
|
763
|
+
install_repl_displayhook()
|
|
764
|
+
return stack
|
|
765
|
+
|
|
766
|
+
|
|
767
|
+
def pause(interval: float) -> None:
|
|
768
|
+
"""
|
|
769
|
+
Run the GUI event loop for *interval* seconds.
|
|
770
|
+
|
|
771
|
+
If there is an active figure, it will be updated and displayed before the
|
|
772
|
+
pause, and the GUI event loop (if any) will run during the pause.
|
|
773
|
+
|
|
774
|
+
This can be used for crude animation. For more complex animation use
|
|
775
|
+
:mod:`matplotlib.animation`.
|
|
776
|
+
|
|
777
|
+
If there is no active figure, sleep for *interval* seconds instead.
|
|
778
|
+
|
|
779
|
+
See Also
|
|
780
|
+
--------
|
|
781
|
+
matplotlib.animation : Proper animations
|
|
782
|
+
show : Show all figures and optional block until all figures are closed.
|
|
783
|
+
"""
|
|
784
|
+
manager = _pylab_helpers.Gcf.get_active()
|
|
785
|
+
if manager is not None:
|
|
786
|
+
canvas = manager.canvas
|
|
787
|
+
if canvas.figure.stale:
|
|
788
|
+
canvas.draw_idle()
|
|
789
|
+
show(block=False)
|
|
790
|
+
canvas.start_event_loop(interval)
|
|
791
|
+
else:
|
|
792
|
+
time.sleep(interval)
|
|
793
|
+
|
|
794
|
+
|
|
795
|
+
@_copy_docstring_and_deprecators(matplotlib.rc)
|
|
796
|
+
def rc(group: RcGroupKeyType, **kwargs) -> None:
|
|
797
|
+
matplotlib.rc(group, **kwargs)
|
|
798
|
+
|
|
799
|
+
|
|
800
|
+
@_copy_docstring_and_deprecators(matplotlib.rc_context)
|
|
801
|
+
def rc_context(
|
|
802
|
+
rc: dict[RcKeyType, Any] | None = None,
|
|
803
|
+
fname: str | pathlib.Path | os.PathLike | None = None,
|
|
804
|
+
) -> AbstractContextManager[None]:
|
|
805
|
+
return matplotlib.rc_context(rc, fname)
|
|
806
|
+
|
|
807
|
+
|
|
808
|
+
@_copy_docstring_and_deprecators(matplotlib.rcdefaults)
|
|
809
|
+
def rcdefaults() -> None:
|
|
810
|
+
matplotlib.rcdefaults()
|
|
811
|
+
if matplotlib.is_interactive():
|
|
812
|
+
draw_all()
|
|
813
|
+
|
|
814
|
+
|
|
815
|
+
# getp/get/setp are explicitly reexported so that they show up in pyplot docs.
|
|
816
|
+
|
|
817
|
+
|
|
818
|
+
@_copy_docstring_and_deprecators(matplotlib.artist.getp)
|
|
819
|
+
def getp(obj, *args, **kwargs):
|
|
820
|
+
return matplotlib.artist.getp(obj, *args, **kwargs)
|
|
821
|
+
|
|
822
|
+
|
|
823
|
+
@_copy_docstring_and_deprecators(matplotlib.artist.get)
|
|
824
|
+
def get(obj, *args, **kwargs):
|
|
825
|
+
return matplotlib.artist.get(obj, *args, **kwargs)
|
|
826
|
+
|
|
827
|
+
|
|
828
|
+
@_copy_docstring_and_deprecators(matplotlib.artist.setp)
|
|
829
|
+
def setp(obj, *args, **kwargs):
|
|
830
|
+
return matplotlib.artist.setp(obj, *args, **kwargs)
|
|
831
|
+
|
|
832
|
+
|
|
833
|
+
def xkcd(
|
|
834
|
+
scale: float = 1, length: float = 100, randomness: float = 2
|
|
835
|
+
) -> ExitStack:
|
|
836
|
+
"""
|
|
837
|
+
Turn on `xkcd <https://xkcd.com/>`_ sketch-style drawing mode.
|
|
838
|
+
|
|
839
|
+
This will only have an effect on things drawn after this function is called.
|
|
840
|
+
|
|
841
|
+
For best results, install the `xkcd script <https://github.com/ipython/xkcd-font/>`_
|
|
842
|
+
font; xkcd fonts are not packaged with Matplotlib.
|
|
843
|
+
|
|
844
|
+
Parameters
|
|
845
|
+
----------
|
|
846
|
+
scale : float, optional
|
|
847
|
+
The amplitude of the wiggle perpendicular to the source line.
|
|
848
|
+
length : float, optional
|
|
849
|
+
The length of the wiggle along the line.
|
|
850
|
+
randomness : float, optional
|
|
851
|
+
The scale factor by which the length is shrunken or expanded.
|
|
852
|
+
|
|
853
|
+
Notes
|
|
854
|
+
-----
|
|
855
|
+
This function works by a number of rcParams, overriding those set before.
|
|
856
|
+
|
|
857
|
+
If you want the effects of this function to be temporary, it can
|
|
858
|
+
be used as a context manager, for example::
|
|
859
|
+
|
|
860
|
+
with plt.xkcd():
|
|
861
|
+
# This figure will be in XKCD-style
|
|
862
|
+
fig1 = plt.figure()
|
|
863
|
+
# ...
|
|
864
|
+
|
|
865
|
+
# This figure will be in regular style
|
|
866
|
+
fig2 = plt.figure()
|
|
867
|
+
"""
|
|
868
|
+
# This cannot be implemented in terms of contextmanager() or rc_context()
|
|
869
|
+
# because this needs to work as a non-contextmanager too.
|
|
870
|
+
|
|
871
|
+
if rcParams['text.usetex']:
|
|
872
|
+
raise RuntimeError(
|
|
873
|
+
"xkcd mode is not compatible with text.usetex = True")
|
|
874
|
+
|
|
875
|
+
stack = ExitStack()
|
|
876
|
+
stack.callback(rcParams._update_raw, rcParams.copy())
|
|
877
|
+
|
|
878
|
+
from matplotlib_rs import patheffects
|
|
879
|
+
rcParams.update({
|
|
880
|
+
'font.family': ['xkcd', 'xkcd Script', 'Comic Neue', 'Comic Sans MS'],
|
|
881
|
+
'font.size': 14.0,
|
|
882
|
+
'path.sketch': (scale, length, randomness),
|
|
883
|
+
'path.effects': [
|
|
884
|
+
patheffects.withStroke(linewidth=4, foreground="w")],
|
|
885
|
+
'axes.linewidth': 1.5,
|
|
886
|
+
'lines.linewidth': 2.0,
|
|
887
|
+
'figure.facecolor': 'white',
|
|
888
|
+
'grid.linewidth': 0.0,
|
|
889
|
+
'axes.grid': False,
|
|
890
|
+
'axes.unicode_minus': False,
|
|
891
|
+
'axes.edgecolor': 'black',
|
|
892
|
+
'xtick.major.size': 8,
|
|
893
|
+
'xtick.major.width': 3,
|
|
894
|
+
'ytick.major.size': 8,
|
|
895
|
+
'ytick.major.width': 3,
|
|
896
|
+
})
|
|
897
|
+
|
|
898
|
+
return stack
|
|
899
|
+
|
|
900
|
+
|
|
901
|
+
## Figures ##
|
|
902
|
+
|
|
903
|
+
def figure(
|
|
904
|
+
# autoincrement if None, else integer from 1-N
|
|
905
|
+
num: int | str | Figure | SubFigure | None = None,
|
|
906
|
+
# defaults to rc figure.figsize
|
|
907
|
+
figsize: ArrayLike # a 2-element ndarray is accepted as well
|
|
908
|
+
| tuple[float, float, Literal["in", "cm", "px"]]
|
|
909
|
+
| None = None,
|
|
910
|
+
# defaults to rc figure.dpi
|
|
911
|
+
dpi: float | None = None,
|
|
912
|
+
*,
|
|
913
|
+
# defaults to rc figure.facecolor
|
|
914
|
+
facecolor: ColorType | None = None,
|
|
915
|
+
# defaults to rc figure.edgecolor
|
|
916
|
+
edgecolor: ColorType | None = None,
|
|
917
|
+
frameon: bool = True,
|
|
918
|
+
FigureClass: type[Figure] = Figure,
|
|
919
|
+
clear: bool = False,
|
|
920
|
+
**kwargs
|
|
921
|
+
) -> Figure:
|
|
922
|
+
"""
|
|
923
|
+
Create a new figure, or activate an existing figure.
|
|
924
|
+
|
|
925
|
+
Parameters
|
|
926
|
+
----------
|
|
927
|
+
num : int or str or `.Figure` or `.SubFigure`, optional
|
|
928
|
+
A unique identifier for the figure.
|
|
929
|
+
|
|
930
|
+
If a figure with that identifier already exists, this figure is made
|
|
931
|
+
active and returned. An integer refers to the ``Figure.number``
|
|
932
|
+
attribute, a string refers to the figure label.
|
|
933
|
+
|
|
934
|
+
If there is no figure with the identifier or *num* is not given, a new
|
|
935
|
+
figure is created, made active and returned. If *num* is an int, it
|
|
936
|
+
will be used for the ``Figure.number`` attribute, otherwise, an
|
|
937
|
+
auto-generated integer value is used (starting at 1 and incremented
|
|
938
|
+
for each new figure). If *num* is a string, the figure label and the
|
|
939
|
+
window title is set to this value. If num is a ``SubFigure``, its
|
|
940
|
+
parent ``Figure`` is activated.
|
|
941
|
+
|
|
942
|
+
If *num* is a Figure instance that is already tracked in pyplot, it is
|
|
943
|
+
activated. If *num* is a Figure instance that is not tracked in pyplot,
|
|
944
|
+
it is added to the tracked figures and activated.
|
|
945
|
+
|
|
946
|
+
figsize : (float, float) or (float, float, str), default: :rc:`figure.figsize`
|
|
947
|
+
The figure dimensions. This can be
|
|
948
|
+
|
|
949
|
+
- a tuple ``(width, height, unit)``, where *unit* is one of "in", "cm",
|
|
950
|
+
"px".
|
|
951
|
+
- a tuple ``(x, y)``, which is interpreted as ``(x, y, "in")``.
|
|
952
|
+
|
|
953
|
+
One of *width* or *height* may be ``None``; the respective value is taken
|
|
954
|
+
from :rc:`figure.figsize`.
|
|
955
|
+
|
|
956
|
+
dpi : float, default: :rc:`figure.dpi`
|
|
957
|
+
The resolution of the figure in dots-per-inch.
|
|
958
|
+
|
|
959
|
+
facecolor : :mpltype:`color`, default: :rc:`figure.facecolor`
|
|
960
|
+
The background color.
|
|
961
|
+
|
|
962
|
+
edgecolor : :mpltype:`color`, default: :rc:`figure.edgecolor`
|
|
963
|
+
The border color.
|
|
964
|
+
|
|
965
|
+
frameon : bool, default: True
|
|
966
|
+
If False, suppress drawing the figure frame.
|
|
967
|
+
|
|
968
|
+
FigureClass : subclass of `~matplotlib.figure.Figure`
|
|
969
|
+
If set, an instance of this subclass will be created, rather than a
|
|
970
|
+
plain `.Figure`.
|
|
971
|
+
|
|
972
|
+
clear : bool, default: False
|
|
973
|
+
If True and the figure already exists, then it is cleared.
|
|
974
|
+
|
|
975
|
+
layout : {'constrained', 'compressed', 'tight', 'none', `.LayoutEngine`, None}, \
|
|
976
|
+
default: None
|
|
977
|
+
The layout mechanism for positioning of plot elements to avoid
|
|
978
|
+
overlapping Axes decorations (labels, ticks, etc). Note that layout
|
|
979
|
+
managers can measurably slow down figure display.
|
|
980
|
+
|
|
981
|
+
- 'constrained': The constrained layout solver adjusts Axes sizes
|
|
982
|
+
to avoid overlapping Axes decorations. Can handle complex plot
|
|
983
|
+
layouts and colorbars, and is thus recommended.
|
|
984
|
+
|
|
985
|
+
See :ref:`constrainedlayout_guide`
|
|
986
|
+
for examples.
|
|
987
|
+
|
|
988
|
+
- 'compressed': uses the same algorithm as 'constrained', but
|
|
989
|
+
removes extra space between fixed-aspect-ratio Axes. Best for
|
|
990
|
+
simple grids of Axes.
|
|
991
|
+
|
|
992
|
+
- 'tight': Use the tight layout mechanism. This is a relatively
|
|
993
|
+
simple algorithm that adjusts the subplot parameters so that
|
|
994
|
+
decorations do not overlap. See `.Figure.set_tight_layout` for
|
|
995
|
+
further details.
|
|
996
|
+
|
|
997
|
+
- 'none': Do not use a layout engine.
|
|
998
|
+
|
|
999
|
+
- A `.LayoutEngine` instance. Builtin layout classes are
|
|
1000
|
+
`.ConstrainedLayoutEngine` and `.TightLayoutEngine`, more easily
|
|
1001
|
+
accessible by 'constrained' and 'tight'. Passing an instance
|
|
1002
|
+
allows third parties to provide their own layout engine.
|
|
1003
|
+
|
|
1004
|
+
If not given, fall back to using the parameters *tight_layout* and
|
|
1005
|
+
*constrained_layout*, including their config defaults
|
|
1006
|
+
:rc:`figure.autolayout` and :rc:`figure.constrained_layout.use`.
|
|
1007
|
+
|
|
1008
|
+
**kwargs
|
|
1009
|
+
Additional keyword arguments are passed to the `.Figure` constructor.
|
|
1010
|
+
|
|
1011
|
+
Returns
|
|
1012
|
+
-------
|
|
1013
|
+
`~matplotlib.figure.Figure`
|
|
1014
|
+
|
|
1015
|
+
Notes
|
|
1016
|
+
-----
|
|
1017
|
+
A newly created figure is passed to the `~.FigureCanvasBase.new_manager`
|
|
1018
|
+
method or the `new_figure_manager` function provided by the current
|
|
1019
|
+
backend, which install a canvas and a manager on the figure.
|
|
1020
|
+
|
|
1021
|
+
Once this is done, :rc:`figure.hooks` are called, one at a time, on the
|
|
1022
|
+
figure; these hooks allow arbitrary customization of the figure (e.g.,
|
|
1023
|
+
attaching callbacks) or of associated elements (e.g., modifying the
|
|
1024
|
+
toolbar). See :doc:`/gallery/user_interfaces/mplcvd` for an example of
|
|
1025
|
+
toolbar customization.
|
|
1026
|
+
|
|
1027
|
+
If you are creating many figures, make sure you explicitly call
|
|
1028
|
+
`.pyplot.close` on the figures you are not using, because this will
|
|
1029
|
+
enable pyplot to properly clean up the memory.
|
|
1030
|
+
|
|
1031
|
+
`~matplotlib.rcParams` defines the default values, which can be modified
|
|
1032
|
+
in the matplotlibrc file.
|
|
1033
|
+
"""
|
|
1034
|
+
allnums = get_fignums()
|
|
1035
|
+
next_num = max(allnums) + 1 if allnums else 1
|
|
1036
|
+
|
|
1037
|
+
if isinstance(num, FigureBase):
|
|
1038
|
+
# type narrowed to `Figure | SubFigure` by combination of input and isinstance
|
|
1039
|
+
has_figure_property_parameters = (
|
|
1040
|
+
any(param is not None for param in [figsize, dpi, facecolor, edgecolor])
|
|
1041
|
+
or not frameon or kwargs
|
|
1042
|
+
)
|
|
1043
|
+
|
|
1044
|
+
root_fig = num.get_figure(root=True)
|
|
1045
|
+
if root_fig.canvas.manager is None:
|
|
1046
|
+
if has_figure_property_parameters:
|
|
1047
|
+
raise ValueError(
|
|
1048
|
+
"You cannot pass figure properties when calling figure() with "
|
|
1049
|
+
"an existing Figure instance")
|
|
1050
|
+
backend = _get_backend_mod()
|
|
1051
|
+
manager_ = backend.new_figure_manager_given_figure(next_num, root_fig)
|
|
1052
|
+
_pylab_helpers.Gcf._set_new_active_manager(manager_)
|
|
1053
|
+
return manager_.canvas.figure
|
|
1054
|
+
elif has_figure_property_parameters and root_fig.canvas.manager.num in allnums:
|
|
1055
|
+
_api.warn_external(
|
|
1056
|
+
"Ignoring specified arguments in this call because figure "
|
|
1057
|
+
f"with num: {root_fig.canvas.manager.num} already exists")
|
|
1058
|
+
_pylab_helpers.Gcf.set_active(root_fig.canvas.manager)
|
|
1059
|
+
return root_fig
|
|
1060
|
+
|
|
1061
|
+
fig_label = ''
|
|
1062
|
+
if num is None:
|
|
1063
|
+
num = next_num
|
|
1064
|
+
else:
|
|
1065
|
+
if (any(param is not None for param in [figsize, dpi, facecolor, edgecolor])
|
|
1066
|
+
or not frameon or kwargs) and num in allnums:
|
|
1067
|
+
_api.warn_external(
|
|
1068
|
+
"Ignoring specified arguments in this call "
|
|
1069
|
+
f"because figure with num: {num} already exists")
|
|
1070
|
+
if isinstance(num, str):
|
|
1071
|
+
fig_label = num
|
|
1072
|
+
all_labels = get_figlabels()
|
|
1073
|
+
if fig_label not in all_labels:
|
|
1074
|
+
if fig_label == 'all':
|
|
1075
|
+
_api.warn_external("close('all') closes all existing figures.")
|
|
1076
|
+
num = next_num
|
|
1077
|
+
else:
|
|
1078
|
+
inum = all_labels.index(fig_label)
|
|
1079
|
+
num = allnums[inum]
|
|
1080
|
+
else:
|
|
1081
|
+
num = int(num) # crude validation of num argument
|
|
1082
|
+
|
|
1083
|
+
manager = _pylab_helpers.Gcf.get_fig_manager(num)
|
|
1084
|
+
if manager is None:
|
|
1085
|
+
max_open_warning = rcParams['figure.max_open_warning']
|
|
1086
|
+
if len(allnums) == max_open_warning >= 1:
|
|
1087
|
+
_api.warn_external(
|
|
1088
|
+
f"More than {max_open_warning} figures have been opened. "
|
|
1089
|
+
f"Figures created through the pyplot interface "
|
|
1090
|
+
f"(`matplotlib.pyplot.figure`) are retained until explicitly "
|
|
1091
|
+
f"closed and may consume too much memory. (To control this "
|
|
1092
|
+
f"warning, see the rcParam `figure.max_open_warning`). "
|
|
1093
|
+
f"Consider using `matplotlib.pyplot.close()`.",
|
|
1094
|
+
RuntimeWarning)
|
|
1095
|
+
|
|
1096
|
+
manager = new_figure_manager(
|
|
1097
|
+
num, figsize=figsize, dpi=dpi,
|
|
1098
|
+
facecolor=facecolor, edgecolor=edgecolor, frameon=frameon,
|
|
1099
|
+
FigureClass=FigureClass, **kwargs)
|
|
1100
|
+
fig = manager.canvas.figure
|
|
1101
|
+
if fig_label:
|
|
1102
|
+
fig.set_label(fig_label)
|
|
1103
|
+
|
|
1104
|
+
for hookspecs in rcParams["figure.hooks"]:
|
|
1105
|
+
module_name, dotted_name = hookspecs.split(":")
|
|
1106
|
+
obj: Any = importlib.import_module(module_name)
|
|
1107
|
+
for part in dotted_name.split("."):
|
|
1108
|
+
obj = getattr(obj, part)
|
|
1109
|
+
obj(fig)
|
|
1110
|
+
|
|
1111
|
+
_pylab_helpers.Gcf._set_new_active_manager(manager)
|
|
1112
|
+
|
|
1113
|
+
# make sure backends (inline) that we don't ship that expect this
|
|
1114
|
+
# to be called in plotting commands to make the figure call show
|
|
1115
|
+
# still work. There is probably a better way to do this in the
|
|
1116
|
+
# FigureManager base class.
|
|
1117
|
+
draw_if_interactive()
|
|
1118
|
+
|
|
1119
|
+
if _REPL_DISPLAYHOOK is _ReplDisplayHook.PLAIN:
|
|
1120
|
+
fig.stale_callback = _auto_draw_if_interactive
|
|
1121
|
+
|
|
1122
|
+
if clear:
|
|
1123
|
+
manager.canvas.figure.clear()
|
|
1124
|
+
|
|
1125
|
+
return manager.canvas.figure
|
|
1126
|
+
|
|
1127
|
+
|
|
1128
|
+
def _auto_draw_if_interactive(fig, val):
|
|
1129
|
+
"""
|
|
1130
|
+
An internal helper function for making sure that auto-redrawing
|
|
1131
|
+
works as intended in the plain python repl.
|
|
1132
|
+
|
|
1133
|
+
Parameters
|
|
1134
|
+
----------
|
|
1135
|
+
fig : Figure
|
|
1136
|
+
A figure object which is assumed to be associated with a canvas
|
|
1137
|
+
"""
|
|
1138
|
+
if (val and matplotlib.is_interactive()
|
|
1139
|
+
and not fig.canvas.is_saving()
|
|
1140
|
+
and not fig.canvas._is_idle_drawing):
|
|
1141
|
+
# Some artists can mark themselves as stale in the middle of drawing
|
|
1142
|
+
# (e.g. axes position & tick labels being computed at draw time), but
|
|
1143
|
+
# this shouldn't trigger a redraw because the current redraw will
|
|
1144
|
+
# already take them into account.
|
|
1145
|
+
with fig.canvas._idle_draw_cntx():
|
|
1146
|
+
fig.canvas.draw_idle()
|
|
1147
|
+
|
|
1148
|
+
|
|
1149
|
+
def gcf() -> Figure:
|
|
1150
|
+
"""
|
|
1151
|
+
Get the current figure.
|
|
1152
|
+
|
|
1153
|
+
If there is currently no figure on the pyplot figure stack, a new one is
|
|
1154
|
+
created using `~.pyplot.figure()`. (To test whether there is currently a
|
|
1155
|
+
figure on the pyplot figure stack, check whether `~.pyplot.get_fignums()`
|
|
1156
|
+
is empty.)
|
|
1157
|
+
"""
|
|
1158
|
+
manager = _pylab_helpers.Gcf.get_active()
|
|
1159
|
+
if manager is not None:
|
|
1160
|
+
return manager.canvas.figure
|
|
1161
|
+
else:
|
|
1162
|
+
return figure()
|
|
1163
|
+
|
|
1164
|
+
|
|
1165
|
+
def fignum_exists(num: int | str) -> bool:
|
|
1166
|
+
"""
|
|
1167
|
+
Return whether the figure with the given id exists.
|
|
1168
|
+
|
|
1169
|
+
Parameters
|
|
1170
|
+
----------
|
|
1171
|
+
num : int or str
|
|
1172
|
+
A figure identifier.
|
|
1173
|
+
|
|
1174
|
+
Returns
|
|
1175
|
+
-------
|
|
1176
|
+
bool
|
|
1177
|
+
Whether or not a figure with id *num* exists.
|
|
1178
|
+
"""
|
|
1179
|
+
return (
|
|
1180
|
+
_pylab_helpers.Gcf.has_fignum(num)
|
|
1181
|
+
if isinstance(num, int)
|
|
1182
|
+
else num in get_figlabels()
|
|
1183
|
+
)
|
|
1184
|
+
|
|
1185
|
+
|
|
1186
|
+
def _raise_if_figure_exists(num, func_name, clear=False):
|
|
1187
|
+
"""
|
|
1188
|
+
Raise a ValueError if the figure *num* already exists.
|
|
1189
|
+
"""
|
|
1190
|
+
if num is not None and not clear:
|
|
1191
|
+
if isinstance(num, FigureBase):
|
|
1192
|
+
raise ValueError(
|
|
1193
|
+
f"num {num!r} cannot be a FigureBase instance. "
|
|
1194
|
+
f"plt.{func_name}() is for creating new figures. "
|
|
1195
|
+
f"To add to an existing figure, use fig.{func_name}() "
|
|
1196
|
+
"instead.")
|
|
1197
|
+
|
|
1198
|
+
if fignum_exists(num):
|
|
1199
|
+
raise ValueError(
|
|
1200
|
+
f"Figure {num!r} already exists. Use plt.figure({num!r}) "
|
|
1201
|
+
f"to get it or plt.close({num!r}) to close it. "
|
|
1202
|
+
f"Alternatively, pass 'clear=True' to {func_name}().")
|
|
1203
|
+
|
|
1204
|
+
|
|
1205
|
+
def get_fignums() -> list[int]:
|
|
1206
|
+
"""Return a list of existing figure numbers."""
|
|
1207
|
+
return sorted(_pylab_helpers.Gcf.figs)
|
|
1208
|
+
|
|
1209
|
+
|
|
1210
|
+
def get_figlabels() -> list[Any]:
|
|
1211
|
+
"""Return a list of existing figure labels."""
|
|
1212
|
+
managers = _pylab_helpers.Gcf.get_all_fig_managers()
|
|
1213
|
+
managers.sort(key=lambda m: m.num)
|
|
1214
|
+
return [m.canvas.figure.get_label() for m in managers]
|
|
1215
|
+
|
|
1216
|
+
|
|
1217
|
+
def get_current_fig_manager() -> FigureManagerBase | None:
|
|
1218
|
+
"""
|
|
1219
|
+
Return the figure manager of the current figure.
|
|
1220
|
+
|
|
1221
|
+
The figure manager is a container for the actual backend-depended window
|
|
1222
|
+
that displays the figure on screen.
|
|
1223
|
+
|
|
1224
|
+
If no current figure exists, a new one is created, and its figure
|
|
1225
|
+
manager is returned.
|
|
1226
|
+
|
|
1227
|
+
Returns
|
|
1228
|
+
-------
|
|
1229
|
+
`.FigureManagerBase` or backend-dependent subclass thereof
|
|
1230
|
+
"""
|
|
1231
|
+
return gcf().canvas.manager
|
|
1232
|
+
|
|
1233
|
+
|
|
1234
|
+
@overload
|
|
1235
|
+
def connect(s: MouseEventType, func: Callable[[MouseEvent], Any]) -> int: ...
|
|
1236
|
+
|
|
1237
|
+
|
|
1238
|
+
@overload
|
|
1239
|
+
def connect(s: KeyEventType, func: Callable[[KeyEvent], Any]) -> int: ...
|
|
1240
|
+
|
|
1241
|
+
|
|
1242
|
+
@overload
|
|
1243
|
+
def connect(s: PickEventType, func: Callable[[PickEvent], Any]) -> int: ...
|
|
1244
|
+
|
|
1245
|
+
|
|
1246
|
+
@overload
|
|
1247
|
+
def connect(s: ResizeEventType, func: Callable[[ResizeEvent], Any]) -> int: ...
|
|
1248
|
+
|
|
1249
|
+
|
|
1250
|
+
@overload
|
|
1251
|
+
def connect(s: CloseEventType, func: Callable[[CloseEvent], Any]) -> int: ...
|
|
1252
|
+
|
|
1253
|
+
|
|
1254
|
+
@overload
|
|
1255
|
+
def connect(s: DrawEventType, func: Callable[[DrawEvent], Any]) -> int: ...
|
|
1256
|
+
|
|
1257
|
+
|
|
1258
|
+
@_copy_docstring_and_deprecators(FigureCanvasBase.mpl_connect)
|
|
1259
|
+
def connect(s, func) -> int:
|
|
1260
|
+
return gcf().canvas.mpl_connect(s, func)
|
|
1261
|
+
|
|
1262
|
+
|
|
1263
|
+
@_copy_docstring_and_deprecators(FigureCanvasBase.mpl_disconnect)
|
|
1264
|
+
def disconnect(cid: int) -> None:
|
|
1265
|
+
gcf().canvas.mpl_disconnect(cid)
|
|
1266
|
+
|
|
1267
|
+
|
|
1268
|
+
def close(fig: None | int | str | Figure | Literal["all"] = None) -> None:
|
|
1269
|
+
"""
|
|
1270
|
+
Close a figure window, and unregister it from pyplot.
|
|
1271
|
+
|
|
1272
|
+
Parameters
|
|
1273
|
+
----------
|
|
1274
|
+
fig : None or int or str or `.Figure`
|
|
1275
|
+
The figure to close. There are a number of ways to specify this:
|
|
1276
|
+
|
|
1277
|
+
- *None*: the current figure
|
|
1278
|
+
- `.Figure`: the given `.Figure` instance
|
|
1279
|
+
- ``int``: a figure number
|
|
1280
|
+
- ``str``: a figure name
|
|
1281
|
+
- 'all': all figures
|
|
1282
|
+
|
|
1283
|
+
Notes
|
|
1284
|
+
-----
|
|
1285
|
+
pyplot maintains a reference to figures created with `figure()`. When
|
|
1286
|
+
work on the figure is completed, it should be closed, i.e. deregistered
|
|
1287
|
+
from pyplot, to free its memory (see also :rc:`figure.max_open_warning`).
|
|
1288
|
+
Closing a figure window created by `show()` automatically deregisters the
|
|
1289
|
+
figure. For all other use cases, most prominently `savefig()` without
|
|
1290
|
+
`show()`, the figure must be deregistered explicitly using `close()`.
|
|
1291
|
+
"""
|
|
1292
|
+
if fig is None:
|
|
1293
|
+
manager = _pylab_helpers.Gcf.get_active()
|
|
1294
|
+
if manager is None:
|
|
1295
|
+
return
|
|
1296
|
+
else:
|
|
1297
|
+
_pylab_helpers.Gcf.destroy(manager)
|
|
1298
|
+
elif fig == 'all':
|
|
1299
|
+
_pylab_helpers.Gcf.destroy_all()
|
|
1300
|
+
elif isinstance(fig, int):
|
|
1301
|
+
_pylab_helpers.Gcf.destroy(fig)
|
|
1302
|
+
elif hasattr(fig, 'int'): # UUIDs get converted to ints by figure().
|
|
1303
|
+
_pylab_helpers.Gcf.destroy(fig.int)
|
|
1304
|
+
elif isinstance(fig, str):
|
|
1305
|
+
all_labels = get_figlabels()
|
|
1306
|
+
if fig in all_labels:
|
|
1307
|
+
num = get_fignums()[all_labels.index(fig)]
|
|
1308
|
+
_pylab_helpers.Gcf.destroy(num)
|
|
1309
|
+
elif isinstance(fig, Figure):
|
|
1310
|
+
_pylab_helpers.Gcf.destroy_fig(fig)
|
|
1311
|
+
else:
|
|
1312
|
+
_api.check_isinstance( # type: ignore[unreachable]
|
|
1313
|
+
(Figure, int, str, None), fig=fig)
|
|
1314
|
+
|
|
1315
|
+
|
|
1316
|
+
def clf() -> None:
|
|
1317
|
+
"""Clear the current figure."""
|
|
1318
|
+
gcf().clear()
|
|
1319
|
+
|
|
1320
|
+
|
|
1321
|
+
def draw() -> None:
|
|
1322
|
+
"""
|
|
1323
|
+
Redraw the current figure.
|
|
1324
|
+
|
|
1325
|
+
This is used to update a figure that has been altered, but not
|
|
1326
|
+
automatically re-drawn. If interactive mode is on (via `.ion()`), this
|
|
1327
|
+
should be only rarely needed, but there may be ways to modify the state of
|
|
1328
|
+
a figure without marking it as "stale". Please report these cases as bugs.
|
|
1329
|
+
|
|
1330
|
+
This is equivalent to calling ``fig.canvas.draw_idle()``, where ``fig`` is
|
|
1331
|
+
the current figure.
|
|
1332
|
+
|
|
1333
|
+
See Also
|
|
1334
|
+
--------
|
|
1335
|
+
.FigureCanvasBase.draw_idle
|
|
1336
|
+
.FigureCanvasBase.draw
|
|
1337
|
+
"""
|
|
1338
|
+
gcf().canvas.draw_idle()
|
|
1339
|
+
|
|
1340
|
+
|
|
1341
|
+
@_copy_docstring_and_deprecators(Figure.savefig)
|
|
1342
|
+
def savefig(fname: str | os.PathLike | IO, **kwargs) -> None:
|
|
1343
|
+
fig = gcf()
|
|
1344
|
+
# savefig default implementation has no return, so mypy is unhappy
|
|
1345
|
+
# presumably this is here because subclasses can return?
|
|
1346
|
+
res = fig.savefig(fname, **kwargs) # type: ignore[func-returns-value]
|
|
1347
|
+
fig.canvas.draw_idle() # Need this if 'transparent=True', to reset colors.
|
|
1348
|
+
return res
|
|
1349
|
+
|
|
1350
|
+
|
|
1351
|
+
## Putting things in figures ##
|
|
1352
|
+
|
|
1353
|
+
|
|
1354
|
+
def figlegend(*args, **kwargs) -> Legend:
|
|
1355
|
+
return gcf().legend(*args, **kwargs)
|
|
1356
|
+
if Figure.legend.__doc__:
|
|
1357
|
+
figlegend.__doc__ = Figure.legend.__doc__ \
|
|
1358
|
+
.replace(" legend(", " figlegend(") \
|
|
1359
|
+
.replace("fig.legend(", "plt.figlegend(") \
|
|
1360
|
+
.replace("ax.plot(", "plt.plot(")
|
|
1361
|
+
|
|
1362
|
+
|
|
1363
|
+
## Axes ##
|
|
1364
|
+
|
|
1365
|
+
@_docstring.interpd
|
|
1366
|
+
def axes(
|
|
1367
|
+
arg: None | tuple[float, float, float, float] = None,
|
|
1368
|
+
**kwargs
|
|
1369
|
+
) -> matplotlib.axes.Axes:
|
|
1370
|
+
"""
|
|
1371
|
+
Add an Axes to the current figure and make it the current Axes.
|
|
1372
|
+
|
|
1373
|
+
Call signatures::
|
|
1374
|
+
|
|
1375
|
+
plt.axes()
|
|
1376
|
+
plt.axes(rect, projection=None, polar=False, **kwargs)
|
|
1377
|
+
plt.axes(ax)
|
|
1378
|
+
|
|
1379
|
+
Parameters
|
|
1380
|
+
----------
|
|
1381
|
+
arg : None or 4-tuple
|
|
1382
|
+
The exact behavior of this function depends on the type:
|
|
1383
|
+
|
|
1384
|
+
- *None*: A new full window Axes is added using
|
|
1385
|
+
``subplot(**kwargs)``.
|
|
1386
|
+
- 4-tuple of float *rect* = ``(left, bottom, width, height)``.
|
|
1387
|
+
A new Axes is added with dimensions *rect* in normalized
|
|
1388
|
+
(0, 1) units using `~.Figure.add_axes` on the current figure.
|
|
1389
|
+
|
|
1390
|
+
projection : {None, 'aitoff', 'hammer', 'lambert', 'mollweide', \
|
|
1391
|
+
'polar', 'rectilinear', str}, optional
|
|
1392
|
+
The projection type of the `~.axes.Axes`. *str* is the name of
|
|
1393
|
+
a custom projection, see `~matplotlib.projections`. The default
|
|
1394
|
+
None results in a 'rectilinear' projection.
|
|
1395
|
+
|
|
1396
|
+
polar : bool, default: False
|
|
1397
|
+
If True, equivalent to projection='polar'.
|
|
1398
|
+
|
|
1399
|
+
sharex, sharey : `~matplotlib.axes.Axes`, optional
|
|
1400
|
+
Share the x or y `~matplotlib.axis` with sharex and/or sharey.
|
|
1401
|
+
The axis will have the same limits, ticks, and scale as the axis
|
|
1402
|
+
of the shared Axes.
|
|
1403
|
+
|
|
1404
|
+
label : str
|
|
1405
|
+
A label for the returned Axes.
|
|
1406
|
+
|
|
1407
|
+
Returns
|
|
1408
|
+
-------
|
|
1409
|
+
`~.axes.Axes`, or a subclass of `~.axes.Axes`
|
|
1410
|
+
The returned Axes class depends on the projection used. It is
|
|
1411
|
+
`~.axes.Axes` if rectilinear projection is used and
|
|
1412
|
+
`.projections.polar.PolarAxes` if polar projection is used.
|
|
1413
|
+
|
|
1414
|
+
Other Parameters
|
|
1415
|
+
----------------
|
|
1416
|
+
**kwargs
|
|
1417
|
+
This method also takes the keyword arguments for
|
|
1418
|
+
the returned Axes class. The keyword arguments for the
|
|
1419
|
+
rectilinear Axes class `~.axes.Axes` can be found in
|
|
1420
|
+
the following table but there might also be other keyword
|
|
1421
|
+
arguments if another projection is used, see the actual Axes
|
|
1422
|
+
class.
|
|
1423
|
+
|
|
1424
|
+
%(Axes:kwdoc)s
|
|
1425
|
+
|
|
1426
|
+
See Also
|
|
1427
|
+
--------
|
|
1428
|
+
.Figure.add_axes
|
|
1429
|
+
.pyplot.subplot
|
|
1430
|
+
.Figure.add_subplot
|
|
1431
|
+
.Figure.subplots
|
|
1432
|
+
.pyplot.subplots
|
|
1433
|
+
|
|
1434
|
+
Examples
|
|
1435
|
+
--------
|
|
1436
|
+
::
|
|
1437
|
+
|
|
1438
|
+
# Creating a new full window Axes
|
|
1439
|
+
plt.axes()
|
|
1440
|
+
|
|
1441
|
+
# Creating a new Axes with specified dimensions and a grey background
|
|
1442
|
+
plt.axes((left, bottom, width, height), facecolor='grey')
|
|
1443
|
+
"""
|
|
1444
|
+
fig = gcf()
|
|
1445
|
+
pos = kwargs.pop('position', None)
|
|
1446
|
+
if arg is None:
|
|
1447
|
+
if pos is None:
|
|
1448
|
+
return fig.add_subplot(**kwargs)
|
|
1449
|
+
else:
|
|
1450
|
+
return fig.add_axes(pos, **kwargs)
|
|
1451
|
+
else:
|
|
1452
|
+
return fig.add_axes(arg, **kwargs)
|
|
1453
|
+
|
|
1454
|
+
|
|
1455
|
+
def delaxes(ax: matplotlib.axes.Axes | None = None) -> None:
|
|
1456
|
+
"""
|
|
1457
|
+
Remove an `~.axes.Axes` (defaulting to the current Axes) from its figure.
|
|
1458
|
+
"""
|
|
1459
|
+
if ax is None:
|
|
1460
|
+
ax = gca()
|
|
1461
|
+
ax.remove()
|
|
1462
|
+
|
|
1463
|
+
|
|
1464
|
+
def sca(ax: Axes) -> None:
|
|
1465
|
+
"""
|
|
1466
|
+
Set the current Axes to *ax* and the current Figure to the parent of *ax*.
|
|
1467
|
+
"""
|
|
1468
|
+
# Mypy sees ax.figure as potentially None,
|
|
1469
|
+
# but if you are calling this, it won't be None
|
|
1470
|
+
# Additionally the slight difference between `Figure` and `FigureBase` mypy catches
|
|
1471
|
+
fig = ax.get_figure(root=False)
|
|
1472
|
+
figure(fig)
|
|
1473
|
+
fig.sca(ax) # type: ignore[union-attr]
|
|
1474
|
+
|
|
1475
|
+
|
|
1476
|
+
def cla() -> None:
|
|
1477
|
+
"""Clear the current Axes."""
|
|
1478
|
+
# Not generated via boilerplate.py to allow a different docstring.
|
|
1479
|
+
return gca().cla()
|
|
1480
|
+
|
|
1481
|
+
|
|
1482
|
+
## More ways of creating Axes ##
|
|
1483
|
+
|
|
1484
|
+
@overload
|
|
1485
|
+
def subplot(nrows: int, ncols: int, index: int, /, **kwargs): ...
|
|
1486
|
+
|
|
1487
|
+
|
|
1488
|
+
@overload
|
|
1489
|
+
def subplot(pos: int | SubplotSpec, /, **kwargs): ...
|
|
1490
|
+
|
|
1491
|
+
|
|
1492
|
+
@overload
|
|
1493
|
+
def subplot(**kwargs): ...
|
|
1494
|
+
|
|
1495
|
+
|
|
1496
|
+
@_docstring.interpd
|
|
1497
|
+
def subplot(*args, **kwargs) -> Axes:
|
|
1498
|
+
"""
|
|
1499
|
+
Add an Axes to the current figure or retrieve an existing Axes.
|
|
1500
|
+
|
|
1501
|
+
This is a wrapper of `.Figure.add_subplot` which provides additional
|
|
1502
|
+
behavior when working with the implicit API (see the notes section).
|
|
1503
|
+
|
|
1504
|
+
Call signatures::
|
|
1505
|
+
|
|
1506
|
+
subplot(nrows, ncols, index, **kwargs)
|
|
1507
|
+
subplot(pos, **kwargs)
|
|
1508
|
+
subplot(**kwargs)
|
|
1509
|
+
|
|
1510
|
+
Parameters
|
|
1511
|
+
----------
|
|
1512
|
+
*args : int, (int, int, *index*), or `.SubplotSpec`, default: (1, 1, 1)
|
|
1513
|
+
The position of the subplot described by one of
|
|
1514
|
+
|
|
1515
|
+
- Three integers (*nrows*, *ncols*, *index*). The subplot will take the
|
|
1516
|
+
*index* position on a grid with *nrows* rows and *ncols* columns.
|
|
1517
|
+
*index* starts at 1 in the upper left corner and increases to the
|
|
1518
|
+
right. *index* can also be a two-tuple specifying the (*first*,
|
|
1519
|
+
*last*) indices (1-based, and including *last*) of the subplot, e.g.,
|
|
1520
|
+
``fig.add_subplot(3, 1, (1, 2))`` makes a subplot that spans the
|
|
1521
|
+
upper 2/3 of the figure.
|
|
1522
|
+
- A 3-digit integer. The digits are interpreted as if given separately
|
|
1523
|
+
as three single-digit integers, i.e. ``fig.add_subplot(235)`` is the
|
|
1524
|
+
same as ``fig.add_subplot(2, 3, 5)``. Note that this can only be used
|
|
1525
|
+
if there are no more than 9 subplots.
|
|
1526
|
+
- A `.SubplotSpec`.
|
|
1527
|
+
|
|
1528
|
+
projection : {None, 'aitoff', 'hammer', 'lambert', 'mollweide', \
|
|
1529
|
+
'polar', 'rectilinear', str}, optional
|
|
1530
|
+
The projection type of the subplot (`~.axes.Axes`). *str* is the name
|
|
1531
|
+
of a custom projection, see `~matplotlib.projections`. The default
|
|
1532
|
+
None results in a 'rectilinear' projection.
|
|
1533
|
+
|
|
1534
|
+
polar : bool, default: False
|
|
1535
|
+
If True, equivalent to projection='polar'.
|
|
1536
|
+
|
|
1537
|
+
sharex, sharey : `~matplotlib.axes.Axes`, optional
|
|
1538
|
+
Share the x or y `~matplotlib.axis` with sharex and/or sharey. The
|
|
1539
|
+
axis will have the same limits, ticks, and scale as the axis of the
|
|
1540
|
+
shared Axes.
|
|
1541
|
+
|
|
1542
|
+
label : str
|
|
1543
|
+
A label for the returned Axes.
|
|
1544
|
+
|
|
1545
|
+
Returns
|
|
1546
|
+
-------
|
|
1547
|
+
`~.axes.Axes`
|
|
1548
|
+
|
|
1549
|
+
The Axes of the subplot. The returned Axes can actually be an instance
|
|
1550
|
+
of a subclass, such as `.projections.polar.PolarAxes` for polar
|
|
1551
|
+
projections.
|
|
1552
|
+
|
|
1553
|
+
Other Parameters
|
|
1554
|
+
----------------
|
|
1555
|
+
**kwargs
|
|
1556
|
+
This method also takes the keyword arguments for the returned Axes
|
|
1557
|
+
base class; except for the *figure* argument. The keyword arguments
|
|
1558
|
+
for the rectilinear base class `~.axes.Axes` can be found in
|
|
1559
|
+
the following table but there might also be other keyword
|
|
1560
|
+
arguments if another projection is used.
|
|
1561
|
+
|
|
1562
|
+
%(Axes:kwdoc)s
|
|
1563
|
+
|
|
1564
|
+
Notes
|
|
1565
|
+
-----
|
|
1566
|
+
.. versionchanged:: 3.8
|
|
1567
|
+
In versions prior to 3.8, any preexisting Axes that overlap with the new Axes
|
|
1568
|
+
beyond sharing a boundary was deleted. Deletion does not happen in more
|
|
1569
|
+
recent versions anymore. Use `.Axes.remove` explicitly if needed.
|
|
1570
|
+
|
|
1571
|
+
If you do not want this behavior, use the `.Figure.add_subplot` method
|
|
1572
|
+
or the `.pyplot.axes` function instead.
|
|
1573
|
+
|
|
1574
|
+
If no *kwargs* are passed and there exists an Axes in the location
|
|
1575
|
+
specified by *args* then that Axes will be returned rather than a new
|
|
1576
|
+
Axes being created.
|
|
1577
|
+
|
|
1578
|
+
If *kwargs* are passed and there exists an Axes in the location
|
|
1579
|
+
specified by *args*, the projection type is the same, and the
|
|
1580
|
+
*kwargs* match with the existing Axes, then the existing Axes is
|
|
1581
|
+
returned. Otherwise a new Axes is created with the specified
|
|
1582
|
+
parameters. We save a reference to the *kwargs* which we use
|
|
1583
|
+
for this comparison. If any of the values in *kwargs* are
|
|
1584
|
+
mutable we will not detect the case where they are mutated.
|
|
1585
|
+
In these cases we suggest using `.Figure.add_subplot` and the
|
|
1586
|
+
explicit Axes API rather than the implicit pyplot API.
|
|
1587
|
+
|
|
1588
|
+
See Also
|
|
1589
|
+
--------
|
|
1590
|
+
.Figure.add_subplot
|
|
1591
|
+
.pyplot.subplots
|
|
1592
|
+
.pyplot.axes
|
|
1593
|
+
.Figure.subplots
|
|
1594
|
+
|
|
1595
|
+
Examples
|
|
1596
|
+
--------
|
|
1597
|
+
::
|
|
1598
|
+
|
|
1599
|
+
plt.subplot(221)
|
|
1600
|
+
|
|
1601
|
+
# equivalent but more general
|
|
1602
|
+
ax1 = plt.subplot(2, 2, 1)
|
|
1603
|
+
|
|
1604
|
+
# add a subplot with no frame
|
|
1605
|
+
ax2 = plt.subplot(222, frameon=False)
|
|
1606
|
+
|
|
1607
|
+
# add a polar subplot
|
|
1608
|
+
plt.subplot(223, projection='polar')
|
|
1609
|
+
|
|
1610
|
+
# add a red subplot that shares the x-axis with ax1
|
|
1611
|
+
plt.subplot(224, sharex=ax1, facecolor='red')
|
|
1612
|
+
|
|
1613
|
+
# delete ax2 from the figure
|
|
1614
|
+
plt.delaxes(ax2)
|
|
1615
|
+
|
|
1616
|
+
# add ax2 to the figure again
|
|
1617
|
+
plt.subplot(ax2)
|
|
1618
|
+
|
|
1619
|
+
# make the first Axes "current" again
|
|
1620
|
+
plt.subplot(221)
|
|
1621
|
+
|
|
1622
|
+
"""
|
|
1623
|
+
# Here we will only normalize `polar=True` vs `projection='polar'` and let
|
|
1624
|
+
# downstream code deal with the rest.
|
|
1625
|
+
unset = object()
|
|
1626
|
+
projection = kwargs.get('projection', unset)
|
|
1627
|
+
polar = kwargs.pop('polar', unset)
|
|
1628
|
+
if polar is not unset and polar:
|
|
1629
|
+
# if we got mixed messages from the user, raise
|
|
1630
|
+
if projection is not unset and projection != 'polar':
|
|
1631
|
+
raise ValueError(
|
|
1632
|
+
f"polar={polar}, yet projection={projection!r}. "
|
|
1633
|
+
"Only one of these arguments should be supplied."
|
|
1634
|
+
)
|
|
1635
|
+
kwargs['projection'] = projection = 'polar'
|
|
1636
|
+
|
|
1637
|
+
# if subplot called without arguments, create subplot(1, 1, 1)
|
|
1638
|
+
if len(args) == 0:
|
|
1639
|
+
args = (1, 1, 1)
|
|
1640
|
+
|
|
1641
|
+
# This check was added because it is very easy to type subplot(1, 2, False)
|
|
1642
|
+
# when subplots(1, 2, False) was intended (sharex=False, that is). In most
|
|
1643
|
+
# cases, no error will ever occur, but mysterious behavior can result
|
|
1644
|
+
# because what was intended to be the sharex argument is instead treated as
|
|
1645
|
+
# a subplot index for subplot()
|
|
1646
|
+
if len(args) >= 3 and isinstance(args[2], bool):
|
|
1647
|
+
_api.warn_external("The subplot index argument to subplot() appears "
|
|
1648
|
+
"to be a boolean. Did you intend to use "
|
|
1649
|
+
"subplots()?")
|
|
1650
|
+
# Check for nrows and ncols, which are not valid subplot args:
|
|
1651
|
+
if 'nrows' in kwargs or 'ncols' in kwargs:
|
|
1652
|
+
raise TypeError("subplot() got an unexpected keyword argument 'ncols' "
|
|
1653
|
+
"and/or 'nrows'. Did you intend to call subplots()?")
|
|
1654
|
+
|
|
1655
|
+
fig = gcf()
|
|
1656
|
+
|
|
1657
|
+
# First, search for an existing subplot with a matching spec.
|
|
1658
|
+
key = SubplotSpec._from_subplot_args(fig, args)
|
|
1659
|
+
|
|
1660
|
+
for ax in fig.axes:
|
|
1661
|
+
# If we found an Axes at the position, we can reuse it if the user passed no
|
|
1662
|
+
# kwargs or if the Axes class and kwargs are identical.
|
|
1663
|
+
if (ax.get_subplotspec() == key
|
|
1664
|
+
and (kwargs == {}
|
|
1665
|
+
or (ax._projection_init
|
|
1666
|
+
== fig._process_projection_requirements(**kwargs)))):
|
|
1667
|
+
break
|
|
1668
|
+
else:
|
|
1669
|
+
# we have exhausted the known Axes and none match, make a new one!
|
|
1670
|
+
ax = fig.add_subplot(*args, **kwargs)
|
|
1671
|
+
|
|
1672
|
+
fig.sca(ax)
|
|
1673
|
+
|
|
1674
|
+
return ax
|
|
1675
|
+
|
|
1676
|
+
|
|
1677
|
+
@overload
|
|
1678
|
+
def subplots(
|
|
1679
|
+
nrows: Literal[1] = ...,
|
|
1680
|
+
ncols: Literal[1] = ...,
|
|
1681
|
+
*,
|
|
1682
|
+
sharex: bool | Literal["none", "all", "row", "col"] = ...,
|
|
1683
|
+
sharey: bool | Literal["none", "all", "row", "col"] = ...,
|
|
1684
|
+
squeeze: Literal[True] = ...,
|
|
1685
|
+
width_ratios: Sequence[float] | None = ...,
|
|
1686
|
+
height_ratios: Sequence[float] | None = ...,
|
|
1687
|
+
subplot_kw: dict[str, Any] | None = ...,
|
|
1688
|
+
gridspec_kw: dict[str, Any] | None = ...,
|
|
1689
|
+
**fig_kw: Any
|
|
1690
|
+
) -> tuple[Figure, Axes]:
|
|
1691
|
+
...
|
|
1692
|
+
|
|
1693
|
+
|
|
1694
|
+
@overload
|
|
1695
|
+
def subplots(
|
|
1696
|
+
nrows: int = ...,
|
|
1697
|
+
ncols: int = ...,
|
|
1698
|
+
*,
|
|
1699
|
+
sharex: bool | Literal["none", "all", "row", "col"] = ...,
|
|
1700
|
+
sharey: bool | Literal["none", "all", "row", "col"] = ...,
|
|
1701
|
+
squeeze: Literal[False],
|
|
1702
|
+
width_ratios: Sequence[float] | None = ...,
|
|
1703
|
+
height_ratios: Sequence[float] | None = ...,
|
|
1704
|
+
subplot_kw: dict[str, Any] | None = ...,
|
|
1705
|
+
gridspec_kw: dict[str, Any] | None = ...,
|
|
1706
|
+
**fig_kw: Any
|
|
1707
|
+
) -> tuple[Figure, np.ndarray]: # TODO numpy/numpy#24738
|
|
1708
|
+
...
|
|
1709
|
+
|
|
1710
|
+
|
|
1711
|
+
@overload
|
|
1712
|
+
def subplots(
|
|
1713
|
+
nrows: int = ...,
|
|
1714
|
+
ncols: int = ...,
|
|
1715
|
+
*,
|
|
1716
|
+
sharex: bool | Literal["none", "all", "row", "col"] = ...,
|
|
1717
|
+
sharey: bool | Literal["none", "all", "row", "col"] = ...,
|
|
1718
|
+
squeeze: bool = ...,
|
|
1719
|
+
width_ratios: Sequence[float] | None = ...,
|
|
1720
|
+
height_ratios: Sequence[float] | None = ...,
|
|
1721
|
+
subplot_kw: dict[str, Any] | None = ...,
|
|
1722
|
+
gridspec_kw: dict[str, Any] | None = ...,
|
|
1723
|
+
**fig_kw: Any
|
|
1724
|
+
) -> tuple[Figure, Any]:
|
|
1725
|
+
...
|
|
1726
|
+
|
|
1727
|
+
|
|
1728
|
+
def subplots(
|
|
1729
|
+
nrows: int = 1, ncols: int = 1, *,
|
|
1730
|
+
sharex: bool | Literal["none", "all", "row", "col"] = False,
|
|
1731
|
+
sharey: bool | Literal["none", "all", "row", "col"] = False,
|
|
1732
|
+
squeeze: bool = True,
|
|
1733
|
+
width_ratios: Sequence[float] | None = None,
|
|
1734
|
+
height_ratios: Sequence[float] | None = None,
|
|
1735
|
+
subplot_kw: dict[str, Any] | None = None,
|
|
1736
|
+
gridspec_kw: dict[str, Any] | None = None,
|
|
1737
|
+
**fig_kw: Any
|
|
1738
|
+
) -> tuple[Figure, Any]:
|
|
1739
|
+
"""
|
|
1740
|
+
Create a figure and a set of subplots.
|
|
1741
|
+
|
|
1742
|
+
This utility wrapper makes it convenient to create common layouts of
|
|
1743
|
+
subplots, including the enclosing figure object, in a single call.
|
|
1744
|
+
|
|
1745
|
+
Parameters
|
|
1746
|
+
----------
|
|
1747
|
+
nrows, ncols : int, default: 1
|
|
1748
|
+
Number of rows/columns of the subplot grid.
|
|
1749
|
+
|
|
1750
|
+
sharex, sharey : bool or {'none', 'all', 'row', 'col'}, default: False
|
|
1751
|
+
Controls sharing of properties among x (*sharex*) or y (*sharey*)
|
|
1752
|
+
axes:
|
|
1753
|
+
|
|
1754
|
+
- True or 'all': x- or y-axis will be shared among all subplots.
|
|
1755
|
+
- False or 'none': each subplot x- or y-axis will be independent.
|
|
1756
|
+
- 'row': each subplot row will share an x- or y-axis.
|
|
1757
|
+
- 'col': each subplot column will share an x- or y-axis.
|
|
1758
|
+
|
|
1759
|
+
When subplots have a shared x-axis along a column, only the x tick
|
|
1760
|
+
labels of the bottom subplot are created. Similarly, when subplots
|
|
1761
|
+
have a shared y-axis along a row, only the y tick labels of the first
|
|
1762
|
+
column subplot are created. To later turn other subplots' ticklabels
|
|
1763
|
+
on, use `~matplotlib.axes.Axes.tick_params`.
|
|
1764
|
+
|
|
1765
|
+
When subplots have a shared axis that has units, calling
|
|
1766
|
+
`.Axis.set_units` will update each axis with the new units.
|
|
1767
|
+
|
|
1768
|
+
Note that it is not possible to unshare axes.
|
|
1769
|
+
|
|
1770
|
+
squeeze : bool, default: True
|
|
1771
|
+
- If True, extra dimensions are squeezed out from the returned
|
|
1772
|
+
array of `~matplotlib.axes.Axes`:
|
|
1773
|
+
|
|
1774
|
+
- if only one subplot is constructed (nrows=ncols=1), the
|
|
1775
|
+
resulting single Axes object is returned as a scalar.
|
|
1776
|
+
- for Nx1 or 1xM subplots, the returned object is a 1D numpy
|
|
1777
|
+
object array of Axes objects.
|
|
1778
|
+
- for NxM, subplots with N>1 and M>1 are returned as a 2D array.
|
|
1779
|
+
|
|
1780
|
+
- If False, no squeezing at all is done: the returned Axes object is
|
|
1781
|
+
always a 2D array containing Axes instances, even if it ends up
|
|
1782
|
+
being 1x1.
|
|
1783
|
+
|
|
1784
|
+
width_ratios : array-like of length *ncols*, optional
|
|
1785
|
+
Defines the relative widths of the columns. Each column gets a
|
|
1786
|
+
relative width of ``width_ratios[i] / sum(width_ratios)``.
|
|
1787
|
+
If not given, all columns will have the same width. Equivalent
|
|
1788
|
+
to ``gridspec_kw={'width_ratios': [...]}``.
|
|
1789
|
+
|
|
1790
|
+
height_ratios : array-like of length *nrows*, optional
|
|
1791
|
+
Defines the relative heights of the rows. Each row gets a
|
|
1792
|
+
relative height of ``height_ratios[i] / sum(height_ratios)``.
|
|
1793
|
+
If not given, all rows will have the same height. Convenience
|
|
1794
|
+
for ``gridspec_kw={'height_ratios': [...]}``.
|
|
1795
|
+
|
|
1796
|
+
subplot_kw : dict, optional
|
|
1797
|
+
Dict with keywords passed to the
|
|
1798
|
+
`~matplotlib.figure.Figure.add_subplot` call used to create each
|
|
1799
|
+
subplot.
|
|
1800
|
+
|
|
1801
|
+
gridspec_kw : dict, optional
|
|
1802
|
+
Dict with keywords passed to the `~matplotlib.gridspec.GridSpec`
|
|
1803
|
+
constructor used to create the grid the subplots are placed on.
|
|
1804
|
+
|
|
1805
|
+
**fig_kw
|
|
1806
|
+
All additional keyword arguments are passed to the
|
|
1807
|
+
`.pyplot.figure` call.
|
|
1808
|
+
|
|
1809
|
+
Returns
|
|
1810
|
+
-------
|
|
1811
|
+
fig : `.Figure`
|
|
1812
|
+
|
|
1813
|
+
ax : `~matplotlib.axes.Axes` or array of Axes
|
|
1814
|
+
*ax* can be either a single `~.axes.Axes` object, or an array of Axes
|
|
1815
|
+
objects if more than one subplot was created. The dimensions of the
|
|
1816
|
+
resulting array can be controlled with the squeeze keyword, see above.
|
|
1817
|
+
|
|
1818
|
+
Typical idioms for handling the return value are::
|
|
1819
|
+
|
|
1820
|
+
# using the variable ax for a single Axes
|
|
1821
|
+
fig, ax = plt.subplots()
|
|
1822
|
+
|
|
1823
|
+
# using the variable axs for multiple Axes
|
|
1824
|
+
fig, axs = plt.subplots(2, 2)
|
|
1825
|
+
|
|
1826
|
+
# using tuple unpacking for multiple Axes
|
|
1827
|
+
fig, (ax1, ax2) = plt.subplots(1, 2)
|
|
1828
|
+
fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2, 2)
|
|
1829
|
+
|
|
1830
|
+
The names ``ax`` and pluralized ``axs`` are preferred over ``axes``
|
|
1831
|
+
because for the latter it's not clear if it refers to a single
|
|
1832
|
+
`~.axes.Axes` instance or a collection of these.
|
|
1833
|
+
|
|
1834
|
+
See Also
|
|
1835
|
+
--------
|
|
1836
|
+
.pyplot.figure
|
|
1837
|
+
.pyplot.subplot
|
|
1838
|
+
.pyplot.axes
|
|
1839
|
+
.Figure.subplots
|
|
1840
|
+
.Figure.add_subplot
|
|
1841
|
+
|
|
1842
|
+
Examples
|
|
1843
|
+
--------
|
|
1844
|
+
::
|
|
1845
|
+
|
|
1846
|
+
# First create some toy data:
|
|
1847
|
+
x = np.linspace(0, 2*np.pi, 400)
|
|
1848
|
+
y = np.sin(x**2)
|
|
1849
|
+
|
|
1850
|
+
# Create just a figure and only one subplot
|
|
1851
|
+
fig, ax = plt.subplots()
|
|
1852
|
+
ax.plot(x, y)
|
|
1853
|
+
ax.set_title('Simple plot')
|
|
1854
|
+
|
|
1855
|
+
# Create two subplots and unpack the output array immediately
|
|
1856
|
+
f, (ax1, ax2) = plt.subplots(1, 2, sharey=True)
|
|
1857
|
+
ax1.plot(x, y)
|
|
1858
|
+
ax1.set_title('Sharing Y axis')
|
|
1859
|
+
ax2.scatter(x, y)
|
|
1860
|
+
|
|
1861
|
+
# Create four polar Axes and access them through the returned array
|
|
1862
|
+
fig, axs = plt.subplots(2, 2, subplot_kw=dict(projection="polar"))
|
|
1863
|
+
axs[0, 0].plot(x, y)
|
|
1864
|
+
axs[1, 1].scatter(x, y)
|
|
1865
|
+
|
|
1866
|
+
# Share an X axis with each column of subplots
|
|
1867
|
+
plt.subplots(2, 2, sharex='col')
|
|
1868
|
+
|
|
1869
|
+
# Share a Y axis with each row of subplots
|
|
1870
|
+
plt.subplots(2, 2, sharey='row')
|
|
1871
|
+
|
|
1872
|
+
# Share both X and Y axes with all subplots
|
|
1873
|
+
plt.subplots(2, 2, sharex='all', sharey='all')
|
|
1874
|
+
|
|
1875
|
+
# Note that this is the same as
|
|
1876
|
+
plt.subplots(2, 2, sharex=True, sharey=True)
|
|
1877
|
+
|
|
1878
|
+
# Create figure number 10 with a single subplot
|
|
1879
|
+
# and clears it if it already exists.
|
|
1880
|
+
fig, ax = plt.subplots(num=10, clear=True)
|
|
1881
|
+
|
|
1882
|
+
"""
|
|
1883
|
+
num = fig_kw.get('num')
|
|
1884
|
+
_raise_if_figure_exists(fig_kw.get('num'), "subplots", fig_kw.get('clear'))
|
|
1885
|
+
|
|
1886
|
+
fig = figure(**fig_kw)
|
|
1887
|
+
axs = fig.subplots(nrows=nrows, ncols=ncols, sharex=sharex, sharey=sharey,
|
|
1888
|
+
squeeze=squeeze, subplot_kw=subplot_kw,
|
|
1889
|
+
gridspec_kw=gridspec_kw, height_ratios=height_ratios,
|
|
1890
|
+
width_ratios=width_ratios)
|
|
1891
|
+
return fig, axs
|
|
1892
|
+
|
|
1893
|
+
|
|
1894
|
+
@overload
|
|
1895
|
+
def subplot_mosaic(
|
|
1896
|
+
mosaic: str,
|
|
1897
|
+
*,
|
|
1898
|
+
sharex: bool = ...,
|
|
1899
|
+
sharey: bool = ...,
|
|
1900
|
+
width_ratios: ArrayLike | None = ...,
|
|
1901
|
+
height_ratios: ArrayLike | None = ...,
|
|
1902
|
+
empty_sentinel: str = ...,
|
|
1903
|
+
subplot_kw: dict[str, Any] | None = ...,
|
|
1904
|
+
gridspec_kw: dict[str, Any] | None = ...,
|
|
1905
|
+
per_subplot_kw: dict[str | tuple[str, ...], dict[str, Any]] | None = ...,
|
|
1906
|
+
**fig_kw: Any
|
|
1907
|
+
) -> tuple[Figure, dict[str, matplotlib.axes.Axes]]: ...
|
|
1908
|
+
|
|
1909
|
+
|
|
1910
|
+
@overload
|
|
1911
|
+
def subplot_mosaic(
|
|
1912
|
+
mosaic: list[HashableList[_T]],
|
|
1913
|
+
*,
|
|
1914
|
+
sharex: bool = ...,
|
|
1915
|
+
sharey: bool = ...,
|
|
1916
|
+
width_ratios: ArrayLike | None = ...,
|
|
1917
|
+
height_ratios: ArrayLike | None = ...,
|
|
1918
|
+
empty_sentinel: _T = ...,
|
|
1919
|
+
subplot_kw: dict[str, Any] | None = ...,
|
|
1920
|
+
gridspec_kw: dict[str, Any] | None = ...,
|
|
1921
|
+
per_subplot_kw: dict[_T | tuple[_T, ...], dict[str, Any]] | None = ...,
|
|
1922
|
+
**fig_kw: Any
|
|
1923
|
+
) -> tuple[Figure, dict[_T, matplotlib.axes.Axes]]: ...
|
|
1924
|
+
|
|
1925
|
+
|
|
1926
|
+
@overload
|
|
1927
|
+
def subplot_mosaic(
|
|
1928
|
+
mosaic: list[HashableList[Hashable]],
|
|
1929
|
+
*,
|
|
1930
|
+
sharex: bool = ...,
|
|
1931
|
+
sharey: bool = ...,
|
|
1932
|
+
width_ratios: ArrayLike | None = ...,
|
|
1933
|
+
height_ratios: ArrayLike | None = ...,
|
|
1934
|
+
empty_sentinel: Any = ...,
|
|
1935
|
+
subplot_kw: dict[str, Any] | None = ...,
|
|
1936
|
+
gridspec_kw: dict[str, Any] | None = ...,
|
|
1937
|
+
per_subplot_kw: dict[Hashable | tuple[Hashable, ...], dict[str, Any]] | None = ...,
|
|
1938
|
+
**fig_kw: Any
|
|
1939
|
+
) -> tuple[Figure, dict[Hashable, matplotlib.axes.Axes]]: ...
|
|
1940
|
+
|
|
1941
|
+
|
|
1942
|
+
def subplot_mosaic(
|
|
1943
|
+
mosaic: str | list[HashableList[_T]] | list[HashableList[Hashable]],
|
|
1944
|
+
*,
|
|
1945
|
+
sharex: bool = False,
|
|
1946
|
+
sharey: bool = False,
|
|
1947
|
+
width_ratios: ArrayLike | None = None,
|
|
1948
|
+
height_ratios: ArrayLike | None = None,
|
|
1949
|
+
empty_sentinel: Any = '.',
|
|
1950
|
+
subplot_kw: dict[str, Any] | None = None,
|
|
1951
|
+
gridspec_kw: dict[str, Any] | None = None,
|
|
1952
|
+
per_subplot_kw: dict[str | tuple[str, ...], dict[str, Any]] |
|
|
1953
|
+
dict[_T | tuple[_T, ...], dict[str, Any]] |
|
|
1954
|
+
dict[Hashable | tuple[Hashable, ...], dict[str, Any]] | None = None,
|
|
1955
|
+
**fig_kw: Any
|
|
1956
|
+
) -> tuple[Figure, dict[str, matplotlib.axes.Axes]] | \
|
|
1957
|
+
tuple[Figure, dict[_T, matplotlib.axes.Axes]] | \
|
|
1958
|
+
tuple[Figure, dict[Hashable, matplotlib.axes.Axes]]:
|
|
1959
|
+
"""
|
|
1960
|
+
Build a layout of Axes based on ASCII art or nested lists.
|
|
1961
|
+
|
|
1962
|
+
This is a helper function to build complex GridSpec layouts visually.
|
|
1963
|
+
|
|
1964
|
+
See :ref:`mosaic`
|
|
1965
|
+
for an example and full API documentation
|
|
1966
|
+
|
|
1967
|
+
Parameters
|
|
1968
|
+
----------
|
|
1969
|
+
mosaic : list of list of {hashable or nested} or str
|
|
1970
|
+
|
|
1971
|
+
A visual layout of how you want your Axes to be arranged
|
|
1972
|
+
labeled as strings. For example ::
|
|
1973
|
+
|
|
1974
|
+
x = [['A panel', 'A panel', 'edge'],
|
|
1975
|
+
['C panel', '.', 'edge']]
|
|
1976
|
+
|
|
1977
|
+
produces 4 Axes:
|
|
1978
|
+
|
|
1979
|
+
- 'A panel' which is 1 row high and spans the first two columns
|
|
1980
|
+
- 'edge' which is 2 rows high and is on the right edge
|
|
1981
|
+
- 'C panel' which in 1 row and 1 column wide in the bottom left
|
|
1982
|
+
- a blank space 1 row and 1 column wide in the bottom center
|
|
1983
|
+
|
|
1984
|
+
Any of the entries in the layout can be a list of lists
|
|
1985
|
+
of the same form to create nested layouts.
|
|
1986
|
+
|
|
1987
|
+
If input is a str, then it must be of the form ::
|
|
1988
|
+
|
|
1989
|
+
'''
|
|
1990
|
+
AAE
|
|
1991
|
+
C.E
|
|
1992
|
+
'''
|
|
1993
|
+
|
|
1994
|
+
where each character is a column and each line is a row.
|
|
1995
|
+
This only allows only single character Axes labels and does
|
|
1996
|
+
not allow nesting but is very terse.
|
|
1997
|
+
|
|
1998
|
+
sharex, sharey : bool, default: False
|
|
1999
|
+
If True, the x-axis (*sharex*) or y-axis (*sharey*) will be shared
|
|
2000
|
+
among all subplots. In that case, tick label visibility and axis units
|
|
2001
|
+
behave as for `subplots`. If False, each subplot's x- or y-axis will
|
|
2002
|
+
be independent.
|
|
2003
|
+
|
|
2004
|
+
width_ratios : array-like of length *ncols*, optional
|
|
2005
|
+
Defines the relative widths of the columns. Each column gets a
|
|
2006
|
+
relative width of ``width_ratios[i] / sum(width_ratios)``.
|
|
2007
|
+
If not given, all columns will have the same width. Convenience
|
|
2008
|
+
for ``gridspec_kw={'width_ratios': [...]}``.
|
|
2009
|
+
|
|
2010
|
+
height_ratios : array-like of length *nrows*, optional
|
|
2011
|
+
Defines the relative heights of the rows. Each row gets a
|
|
2012
|
+
relative height of ``height_ratios[i] / sum(height_ratios)``.
|
|
2013
|
+
If not given, all rows will have the same height. Convenience
|
|
2014
|
+
for ``gridspec_kw={'height_ratios': [...]}``.
|
|
2015
|
+
|
|
2016
|
+
empty_sentinel : object, optional
|
|
2017
|
+
Entry in the layout to mean "leave this space empty". Defaults
|
|
2018
|
+
to ``'.'``. Note, if *layout* is a string, it is processed via
|
|
2019
|
+
`inspect.cleandoc` to remove leading white space, which may
|
|
2020
|
+
interfere with using white-space as the empty sentinel.
|
|
2021
|
+
|
|
2022
|
+
subplot_kw : dict, optional
|
|
2023
|
+
Dictionary with keywords passed to the `.Figure.add_subplot` call
|
|
2024
|
+
used to create each subplot. These values may be overridden by
|
|
2025
|
+
values in *per_subplot_kw*.
|
|
2026
|
+
|
|
2027
|
+
per_subplot_kw : dict, optional
|
|
2028
|
+
A dictionary mapping the Axes identifiers or tuples of identifiers
|
|
2029
|
+
to a dictionary of keyword arguments to be passed to the
|
|
2030
|
+
`.Figure.add_subplot` call used to create each subplot. The values
|
|
2031
|
+
in these dictionaries have precedence over the values in
|
|
2032
|
+
*subplot_kw*.
|
|
2033
|
+
|
|
2034
|
+
If *mosaic* is a string, and thus all keys are single characters,
|
|
2035
|
+
it is possible to use a single string instead of a tuple as keys;
|
|
2036
|
+
i.e. ``"AB"`` is equivalent to ``("A", "B")``.
|
|
2037
|
+
|
|
2038
|
+
.. versionadded:: 3.7
|
|
2039
|
+
|
|
2040
|
+
gridspec_kw : dict, optional
|
|
2041
|
+
Dictionary with keywords passed to the `.GridSpec` constructor used
|
|
2042
|
+
to create the grid the subplots are placed on.
|
|
2043
|
+
|
|
2044
|
+
**fig_kw
|
|
2045
|
+
All additional keyword arguments are passed to the
|
|
2046
|
+
`.pyplot.figure` call.
|
|
2047
|
+
|
|
2048
|
+
Returns
|
|
2049
|
+
-------
|
|
2050
|
+
fig : `.Figure`
|
|
2051
|
+
The new figure
|
|
2052
|
+
|
|
2053
|
+
dict[label, Axes]
|
|
2054
|
+
A dictionary mapping the labels to the Axes objects. The order of
|
|
2055
|
+
the Axes is left-to-right and top-to-bottom of their position in the
|
|
2056
|
+
total layout.
|
|
2057
|
+
|
|
2058
|
+
"""
|
|
2059
|
+
num = fig_kw.get('num')
|
|
2060
|
+
_raise_if_figure_exists(fig_kw.get('num'), "subplot_mosaic", fig_kw.get('clear'))
|
|
2061
|
+
|
|
2062
|
+
fig = figure(**fig_kw)
|
|
2063
|
+
ax_dict = fig.subplot_mosaic( # type: ignore[misc]
|
|
2064
|
+
mosaic, # type: ignore[arg-type]
|
|
2065
|
+
sharex=sharex, sharey=sharey,
|
|
2066
|
+
height_ratios=height_ratios, width_ratios=width_ratios,
|
|
2067
|
+
subplot_kw=subplot_kw, gridspec_kw=gridspec_kw,
|
|
2068
|
+
empty_sentinel=empty_sentinel,
|
|
2069
|
+
per_subplot_kw=per_subplot_kw, # type: ignore[arg-type]
|
|
2070
|
+
)
|
|
2071
|
+
return fig, ax_dict
|
|
2072
|
+
|
|
2073
|
+
|
|
2074
|
+
def subplot2grid(
|
|
2075
|
+
shape: tuple[int, int], loc: tuple[int, int],
|
|
2076
|
+
rowspan: int = 1, colspan: int = 1,
|
|
2077
|
+
fig: Figure | None = None,
|
|
2078
|
+
**kwargs
|
|
2079
|
+
) -> matplotlib.axes.Axes:
|
|
2080
|
+
"""
|
|
2081
|
+
Create a subplot at a specific location inside a regular grid.
|
|
2082
|
+
|
|
2083
|
+
Parameters
|
|
2084
|
+
----------
|
|
2085
|
+
shape : (int, int)
|
|
2086
|
+
Number of rows and of columns of the grid in which to place axis.
|
|
2087
|
+
loc : (int, int)
|
|
2088
|
+
Row number and column number of the axis location within the grid.
|
|
2089
|
+
rowspan : int, default: 1
|
|
2090
|
+
Number of rows for the axis to span downwards.
|
|
2091
|
+
colspan : int, default: 1
|
|
2092
|
+
Number of columns for the axis to span to the right.
|
|
2093
|
+
fig : `.Figure`, optional
|
|
2094
|
+
Figure to place the subplot in. Defaults to the current figure.
|
|
2095
|
+
**kwargs
|
|
2096
|
+
Additional keyword arguments are handed to `~.Figure.add_subplot`.
|
|
2097
|
+
|
|
2098
|
+
Returns
|
|
2099
|
+
-------
|
|
2100
|
+
`~.axes.Axes`
|
|
2101
|
+
|
|
2102
|
+
The Axes of the subplot. The returned Axes can actually be an instance
|
|
2103
|
+
of a subclass, such as `.projections.polar.PolarAxes` for polar
|
|
2104
|
+
projections.
|
|
2105
|
+
|
|
2106
|
+
Notes
|
|
2107
|
+
-----
|
|
2108
|
+
The following call ::
|
|
2109
|
+
|
|
2110
|
+
ax = subplot2grid((nrows, ncols), (row, col), rowspan, colspan)
|
|
2111
|
+
|
|
2112
|
+
is identical to ::
|
|
2113
|
+
|
|
2114
|
+
fig = gcf()
|
|
2115
|
+
gs = fig.add_gridspec(nrows, ncols)
|
|
2116
|
+
ax = fig.add_subplot(gs[row:row+rowspan, col:col+colspan])
|
|
2117
|
+
"""
|
|
2118
|
+
if fig is None:
|
|
2119
|
+
fig = gcf()
|
|
2120
|
+
rows, cols = shape
|
|
2121
|
+
gs = GridSpec._check_gridspec_exists(fig, rows, cols)
|
|
2122
|
+
subplotspec = gs.new_subplotspec(loc, rowspan=rowspan, colspan=colspan)
|
|
2123
|
+
return fig.add_subplot(subplotspec, **kwargs)
|
|
2124
|
+
|
|
2125
|
+
|
|
2126
|
+
def twinx(ax: matplotlib.axes.Axes | None = None) -> _AxesBase:
|
|
2127
|
+
"""
|
|
2128
|
+
Make and return a second Axes that shares the *x*-axis. The new Axes will
|
|
2129
|
+
overlay *ax* (or the current Axes if *ax* is *None*), and its ticks will be
|
|
2130
|
+
on the right.
|
|
2131
|
+
|
|
2132
|
+
Examples
|
|
2133
|
+
--------
|
|
2134
|
+
:doc:`/gallery/subplots_axes_and_figures/two_scales`
|
|
2135
|
+
"""
|
|
2136
|
+
if ax is None:
|
|
2137
|
+
ax = gca()
|
|
2138
|
+
ax1 = ax.twinx()
|
|
2139
|
+
return ax1
|
|
2140
|
+
|
|
2141
|
+
|
|
2142
|
+
def twiny(ax: matplotlib.axes.Axes | None = None) -> _AxesBase:
|
|
2143
|
+
"""
|
|
2144
|
+
Make and return a second Axes that shares the *y*-axis. The new Axes will
|
|
2145
|
+
overlay *ax* (or the current Axes if *ax* is *None*), and its ticks will be
|
|
2146
|
+
on the top.
|
|
2147
|
+
|
|
2148
|
+
Examples
|
|
2149
|
+
--------
|
|
2150
|
+
:doc:`/gallery/subplots_axes_and_figures/two_scales`
|
|
2151
|
+
"""
|
|
2152
|
+
if ax is None:
|
|
2153
|
+
ax = gca()
|
|
2154
|
+
ax1 = ax.twiny()
|
|
2155
|
+
return ax1
|
|
2156
|
+
|
|
2157
|
+
|
|
2158
|
+
def subplot_tool(targetfig: Figure | None = None) -> SubplotTool | None:
|
|
2159
|
+
"""
|
|
2160
|
+
Launch a subplot tool window for a figure.
|
|
2161
|
+
|
|
2162
|
+
Returns
|
|
2163
|
+
-------
|
|
2164
|
+
`matplotlib.widgets.SubplotTool`
|
|
2165
|
+
"""
|
|
2166
|
+
if targetfig is None:
|
|
2167
|
+
targetfig = gcf()
|
|
2168
|
+
tb = targetfig.canvas.manager.toolbar # type: ignore[union-attr]
|
|
2169
|
+
if hasattr(tb, "configure_subplots"): # toolbar2
|
|
2170
|
+
from matplotlib_rs.backend_bases import NavigationToolbar2
|
|
2171
|
+
return cast(NavigationToolbar2, tb).configure_subplots()
|
|
2172
|
+
elif hasattr(tb, "trigger_tool"): # toolmanager
|
|
2173
|
+
from matplotlib_rs.backend_bases import ToolContainerBase
|
|
2174
|
+
cast(ToolContainerBase, tb).trigger_tool("subplots")
|
|
2175
|
+
return None
|
|
2176
|
+
else:
|
|
2177
|
+
raise ValueError("subplot_tool can only be launched for figures with "
|
|
2178
|
+
"an associated toolbar")
|
|
2179
|
+
|
|
2180
|
+
|
|
2181
|
+
def box(on: bool | None = None) -> None:
|
|
2182
|
+
"""
|
|
2183
|
+
Turn the Axes box on or off on the current Axes.
|
|
2184
|
+
|
|
2185
|
+
Parameters
|
|
2186
|
+
----------
|
|
2187
|
+
on : bool or None
|
|
2188
|
+
The new `~matplotlib.axes.Axes` box state. If ``None``, toggle
|
|
2189
|
+
the state.
|
|
2190
|
+
|
|
2191
|
+
See Also
|
|
2192
|
+
--------
|
|
2193
|
+
:meth:`matplotlib.axes.Axes.set_frame_on`
|
|
2194
|
+
:meth:`matplotlib.axes.Axes.get_frame_on`
|
|
2195
|
+
"""
|
|
2196
|
+
ax = gca()
|
|
2197
|
+
if on is None:
|
|
2198
|
+
on = not ax.get_frame_on()
|
|
2199
|
+
ax.set_frame_on(on)
|
|
2200
|
+
|
|
2201
|
+
## Axis ##
|
|
2202
|
+
|
|
2203
|
+
|
|
2204
|
+
@overload
|
|
2205
|
+
def xlim() -> tuple[float, float]:
|
|
2206
|
+
...
|
|
2207
|
+
|
|
2208
|
+
|
|
2209
|
+
@overload
|
|
2210
|
+
def xlim(
|
|
2211
|
+
left: float | tuple[float, float] | None = None,
|
|
2212
|
+
right: float | None = None,
|
|
2213
|
+
*,
|
|
2214
|
+
emit: bool = True,
|
|
2215
|
+
auto: bool | None = False,
|
|
2216
|
+
xmin: float | None = None,
|
|
2217
|
+
xmax: float | None = None,
|
|
2218
|
+
) -> tuple[float, float]:
|
|
2219
|
+
...
|
|
2220
|
+
|
|
2221
|
+
|
|
2222
|
+
def xlim(*args, **kwargs) -> tuple[float, float]:
|
|
2223
|
+
"""
|
|
2224
|
+
Get or set the x limits of the current Axes.
|
|
2225
|
+
|
|
2226
|
+
Call signatures::
|
|
2227
|
+
|
|
2228
|
+
left, right = xlim() # return the current xlim
|
|
2229
|
+
xlim((left, right)) # set the xlim to left, right
|
|
2230
|
+
xlim(left, right) # set the xlim to left, right
|
|
2231
|
+
|
|
2232
|
+
If you do not specify args, you can pass *left* or *right* as kwargs,
|
|
2233
|
+
i.e.::
|
|
2234
|
+
|
|
2235
|
+
xlim(right=3) # adjust the right leaving left unchanged
|
|
2236
|
+
xlim(left=1) # adjust the left leaving right unchanged
|
|
2237
|
+
|
|
2238
|
+
Setting limits turns autoscaling off for the x-axis.
|
|
2239
|
+
|
|
2240
|
+
Returns
|
|
2241
|
+
-------
|
|
2242
|
+
left, right
|
|
2243
|
+
A tuple of the new x-axis limits.
|
|
2244
|
+
|
|
2245
|
+
Notes
|
|
2246
|
+
-----
|
|
2247
|
+
Calling this function with no arguments (e.g. ``xlim()``) is the pyplot
|
|
2248
|
+
equivalent of calling `~.Axes.get_xlim` on the current Axes.
|
|
2249
|
+
Calling this function with arguments is the pyplot equivalent of calling
|
|
2250
|
+
`~.Axes.set_xlim` on the current Axes. All arguments are passed though.
|
|
2251
|
+
"""
|
|
2252
|
+
ax = gca()
|
|
2253
|
+
if not args and not kwargs:
|
|
2254
|
+
return ax.get_xlim()
|
|
2255
|
+
ret = ax.set_xlim(*args, **kwargs)
|
|
2256
|
+
return ret
|
|
2257
|
+
|
|
2258
|
+
|
|
2259
|
+
@overload
|
|
2260
|
+
def ylim() -> tuple[float, float]:
|
|
2261
|
+
...
|
|
2262
|
+
|
|
2263
|
+
|
|
2264
|
+
@overload
|
|
2265
|
+
def ylim(
|
|
2266
|
+
bottom: float | tuple[float, float] | None = None,
|
|
2267
|
+
top: float | None = None,
|
|
2268
|
+
*,
|
|
2269
|
+
emit: bool = True,
|
|
2270
|
+
auto: bool | None = False,
|
|
2271
|
+
ymin: float | None = None,
|
|
2272
|
+
ymax: float | None = None,
|
|
2273
|
+
) -> tuple[float, float]:
|
|
2274
|
+
...
|
|
2275
|
+
|
|
2276
|
+
|
|
2277
|
+
def ylim(*args, **kwargs) -> tuple[float, float]:
|
|
2278
|
+
"""
|
|
2279
|
+
Get or set the y-limits of the current Axes.
|
|
2280
|
+
|
|
2281
|
+
Call signatures::
|
|
2282
|
+
|
|
2283
|
+
bottom, top = ylim() # return the current ylim
|
|
2284
|
+
ylim((bottom, top)) # set the ylim to bottom, top
|
|
2285
|
+
ylim(bottom, top) # set the ylim to bottom, top
|
|
2286
|
+
|
|
2287
|
+
If you do not specify args, you can alternatively pass *bottom* or
|
|
2288
|
+
*top* as kwargs, i.e.::
|
|
2289
|
+
|
|
2290
|
+
ylim(top=3) # adjust the top leaving bottom unchanged
|
|
2291
|
+
ylim(bottom=1) # adjust the bottom leaving top unchanged
|
|
2292
|
+
|
|
2293
|
+
Setting limits turns autoscaling off for the y-axis.
|
|
2294
|
+
|
|
2295
|
+
Returns
|
|
2296
|
+
-------
|
|
2297
|
+
bottom, top
|
|
2298
|
+
A tuple of the new y-axis limits.
|
|
2299
|
+
|
|
2300
|
+
Notes
|
|
2301
|
+
-----
|
|
2302
|
+
Calling this function with no arguments (e.g. ``ylim()``) is the pyplot
|
|
2303
|
+
equivalent of calling `~.Axes.get_ylim` on the current Axes.
|
|
2304
|
+
Calling this function with arguments is the pyplot equivalent of calling
|
|
2305
|
+
`~.Axes.set_ylim` on the current Axes. All arguments are passed though.
|
|
2306
|
+
"""
|
|
2307
|
+
ax = gca()
|
|
2308
|
+
if not args and not kwargs:
|
|
2309
|
+
return ax.get_ylim()
|
|
2310
|
+
ret = ax.set_ylim(*args, **kwargs)
|
|
2311
|
+
return ret
|
|
2312
|
+
|
|
2313
|
+
|
|
2314
|
+
def xticks(
|
|
2315
|
+
ticks: ArrayLike | None = None,
|
|
2316
|
+
labels: Sequence[str] | None = None,
|
|
2317
|
+
*,
|
|
2318
|
+
minor: bool = False,
|
|
2319
|
+
**kwargs
|
|
2320
|
+
) -> tuple[list[Tick] | np.ndarray, list[Text]]:
|
|
2321
|
+
"""
|
|
2322
|
+
Get or set the current tick locations and labels of the x-axis.
|
|
2323
|
+
|
|
2324
|
+
Pass no arguments to return the current values without modifying them.
|
|
2325
|
+
|
|
2326
|
+
Parameters
|
|
2327
|
+
----------
|
|
2328
|
+
ticks : array-like, optional
|
|
2329
|
+
The list of xtick locations. Passing an empty list removes all xticks.
|
|
2330
|
+
labels : array-like, optional
|
|
2331
|
+
The labels to place at the given *ticks* locations. This argument can
|
|
2332
|
+
only be passed if *ticks* is passed as well.
|
|
2333
|
+
minor : bool, default: False
|
|
2334
|
+
If ``False``, get/set the major ticks/labels; if ``True``, the minor
|
|
2335
|
+
ticks/labels.
|
|
2336
|
+
**kwargs
|
|
2337
|
+
`.Text` properties can be used to control the appearance of the labels.
|
|
2338
|
+
|
|
2339
|
+
.. warning::
|
|
2340
|
+
|
|
2341
|
+
This only sets the properties of the current ticks, which is
|
|
2342
|
+
only sufficient if you either pass *ticks*, resulting in a
|
|
2343
|
+
fixed list of ticks, or if the plot is static.
|
|
2344
|
+
|
|
2345
|
+
Ticks are not guaranteed to be persistent. Various operations
|
|
2346
|
+
can create, delete and modify the Tick instances. There is an
|
|
2347
|
+
imminent risk that these settings can get lost if you work on
|
|
2348
|
+
the figure further (including also panning/zooming on a
|
|
2349
|
+
displayed figure).
|
|
2350
|
+
|
|
2351
|
+
Use `~.pyplot.tick_params` instead if possible.
|
|
2352
|
+
|
|
2353
|
+
|
|
2354
|
+
Returns
|
|
2355
|
+
-------
|
|
2356
|
+
locs
|
|
2357
|
+
The list of xtick locations.
|
|
2358
|
+
labels
|
|
2359
|
+
The list of xlabel `.Text` objects.
|
|
2360
|
+
|
|
2361
|
+
Notes
|
|
2362
|
+
-----
|
|
2363
|
+
Calling this function with no arguments (e.g. ``xticks()``) is the pyplot
|
|
2364
|
+
equivalent of calling `~.Axes.get_xticks` and `~.Axes.get_xticklabels` on
|
|
2365
|
+
the current Axes.
|
|
2366
|
+
Calling this function with arguments is the pyplot equivalent of calling
|
|
2367
|
+
`~.Axes.set_xticks` and `~.Axes.set_xticklabels` on the current Axes.
|
|
2368
|
+
|
|
2369
|
+
Examples
|
|
2370
|
+
--------
|
|
2371
|
+
>>> locs, labels = xticks() # Get the current locations and labels.
|
|
2372
|
+
>>> xticks(np.arange(0, 1, step=0.2)) # Set label locations.
|
|
2373
|
+
>>> xticks(np.arange(3), ['Tom', 'Dick', 'Sue']) # Set text labels.
|
|
2374
|
+
>>> xticks([0, 1, 2], ['January', 'February', 'March'],
|
|
2375
|
+
... rotation=20) # Set text labels and properties.
|
|
2376
|
+
>>> xticks([]) # Disable xticks.
|
|
2377
|
+
"""
|
|
2378
|
+
ax = gca()
|
|
2379
|
+
|
|
2380
|
+
locs: list[Tick] | np.ndarray
|
|
2381
|
+
if ticks is None:
|
|
2382
|
+
locs = ax.get_xticks(minor=minor)
|
|
2383
|
+
if labels is not None:
|
|
2384
|
+
raise TypeError("xticks(): Parameter 'labels' can't be set "
|
|
2385
|
+
"without setting 'ticks'")
|
|
2386
|
+
else:
|
|
2387
|
+
locs = ax.set_xticks(ticks, minor=minor)
|
|
2388
|
+
|
|
2389
|
+
labels_out: list[Text] = []
|
|
2390
|
+
if labels is None:
|
|
2391
|
+
labels_out = ax.get_xticklabels(minor=minor)
|
|
2392
|
+
for l in labels_out:
|
|
2393
|
+
l._internal_update(kwargs)
|
|
2394
|
+
else:
|
|
2395
|
+
labels_out = ax.set_xticklabels(labels, minor=minor, **kwargs)
|
|
2396
|
+
|
|
2397
|
+
return locs, labels_out
|
|
2398
|
+
|
|
2399
|
+
|
|
2400
|
+
def yticks(
|
|
2401
|
+
ticks: ArrayLike | None = None,
|
|
2402
|
+
labels: Sequence[str] | None = None,
|
|
2403
|
+
*,
|
|
2404
|
+
minor: bool = False,
|
|
2405
|
+
**kwargs
|
|
2406
|
+
) -> tuple[list[Tick] | np.ndarray, list[Text]]:
|
|
2407
|
+
"""
|
|
2408
|
+
Get or set the current tick locations and labels of the y-axis.
|
|
2409
|
+
|
|
2410
|
+
Pass no arguments to return the current values without modifying them.
|
|
2411
|
+
|
|
2412
|
+
Parameters
|
|
2413
|
+
----------
|
|
2414
|
+
ticks : array-like, optional
|
|
2415
|
+
The list of ytick locations. Passing an empty list removes all yticks.
|
|
2416
|
+
labels : array-like, optional
|
|
2417
|
+
The labels to place at the given *ticks* locations. This argument can
|
|
2418
|
+
only be passed if *ticks* is passed as well.
|
|
2419
|
+
minor : bool, default: False
|
|
2420
|
+
If ``False``, get/set the major ticks/labels; if ``True``, the minor
|
|
2421
|
+
ticks/labels.
|
|
2422
|
+
**kwargs
|
|
2423
|
+
`.Text` properties can be used to control the appearance of the labels.
|
|
2424
|
+
|
|
2425
|
+
.. warning::
|
|
2426
|
+
|
|
2427
|
+
This only sets the properties of the current ticks, which is
|
|
2428
|
+
only sufficient if you either pass *ticks*, resulting in a
|
|
2429
|
+
fixed list of ticks, or if the plot is static.
|
|
2430
|
+
|
|
2431
|
+
Ticks are not guaranteed to be persistent. Various operations
|
|
2432
|
+
can create, delete and modify the Tick instances. There is an
|
|
2433
|
+
imminent risk that these settings can get lost if you work on
|
|
2434
|
+
the figure further (including also panning/zooming on a
|
|
2435
|
+
displayed figure).
|
|
2436
|
+
|
|
2437
|
+
Use `~.pyplot.tick_params` instead if possible.
|
|
2438
|
+
|
|
2439
|
+
Returns
|
|
2440
|
+
-------
|
|
2441
|
+
locs
|
|
2442
|
+
The list of ytick locations.
|
|
2443
|
+
labels
|
|
2444
|
+
The list of ylabel `.Text` objects.
|
|
2445
|
+
|
|
2446
|
+
Notes
|
|
2447
|
+
-----
|
|
2448
|
+
Calling this function with no arguments (e.g. ``yticks()``) is the pyplot
|
|
2449
|
+
equivalent of calling `~.Axes.get_yticks` and `~.Axes.get_yticklabels` on
|
|
2450
|
+
the current Axes.
|
|
2451
|
+
Calling this function with arguments is the pyplot equivalent of calling
|
|
2452
|
+
`~.Axes.set_yticks` and `~.Axes.set_yticklabels` on the current Axes.
|
|
2453
|
+
|
|
2454
|
+
Examples
|
|
2455
|
+
--------
|
|
2456
|
+
>>> locs, labels = yticks() # Get the current locations and labels.
|
|
2457
|
+
>>> yticks(np.arange(0, 1, step=0.2)) # Set label locations.
|
|
2458
|
+
>>> yticks(np.arange(3), ['Tom', 'Dick', 'Sue']) # Set text labels.
|
|
2459
|
+
>>> yticks([0, 1, 2], ['January', 'February', 'March'],
|
|
2460
|
+
... rotation=45) # Set text labels and properties.
|
|
2461
|
+
>>> yticks([]) # Disable yticks.
|
|
2462
|
+
"""
|
|
2463
|
+
ax = gca()
|
|
2464
|
+
|
|
2465
|
+
locs: list[Tick] | np.ndarray
|
|
2466
|
+
if ticks is None:
|
|
2467
|
+
locs = ax.get_yticks(minor=minor)
|
|
2468
|
+
if labels is not None:
|
|
2469
|
+
raise TypeError("yticks(): Parameter 'labels' can't be set "
|
|
2470
|
+
"without setting 'ticks'")
|
|
2471
|
+
else:
|
|
2472
|
+
locs = ax.set_yticks(ticks, minor=minor)
|
|
2473
|
+
|
|
2474
|
+
labels_out: list[Text] = []
|
|
2475
|
+
if labels is None:
|
|
2476
|
+
labels_out = ax.get_yticklabels(minor=minor)
|
|
2477
|
+
for l in labels_out:
|
|
2478
|
+
l._internal_update(kwargs)
|
|
2479
|
+
else:
|
|
2480
|
+
labels_out = ax.set_yticklabels(labels, minor=minor, **kwargs)
|
|
2481
|
+
|
|
2482
|
+
return locs, labels_out
|
|
2483
|
+
|
|
2484
|
+
|
|
2485
|
+
def rgrids(
|
|
2486
|
+
radii: ArrayLike | None = None,
|
|
2487
|
+
labels: Sequence[str | Text] | None = None,
|
|
2488
|
+
angle: float | None = None,
|
|
2489
|
+
fmt: str | None = None,
|
|
2490
|
+
**kwargs
|
|
2491
|
+
) -> tuple[list[Line2D], list[Text]]:
|
|
2492
|
+
"""
|
|
2493
|
+
Get or set the radial gridlines on the current polar plot.
|
|
2494
|
+
|
|
2495
|
+
Call signatures::
|
|
2496
|
+
|
|
2497
|
+
lines, labels = rgrids()
|
|
2498
|
+
lines, labels = rgrids(radii, labels=None, angle=22.5, fmt=None, **kwargs)
|
|
2499
|
+
|
|
2500
|
+
When called with no arguments, `.rgrids` simply returns the tuple
|
|
2501
|
+
(*lines*, *labels*). When called with arguments, the labels will
|
|
2502
|
+
appear at the specified radial distances and angle.
|
|
2503
|
+
|
|
2504
|
+
Parameters
|
|
2505
|
+
----------
|
|
2506
|
+
radii : tuple with floats
|
|
2507
|
+
The radii for the radial gridlines
|
|
2508
|
+
|
|
2509
|
+
labels : tuple with strings or None
|
|
2510
|
+
The labels to use at each radial gridline. The
|
|
2511
|
+
`matplotlib.ticker.ScalarFormatter` will be used if None.
|
|
2512
|
+
|
|
2513
|
+
angle : float
|
|
2514
|
+
The angular position of the radius labels in degrees.
|
|
2515
|
+
|
|
2516
|
+
fmt : str or None
|
|
2517
|
+
Format string used in `matplotlib.ticker.FormatStrFormatter`.
|
|
2518
|
+
For example '%f'.
|
|
2519
|
+
|
|
2520
|
+
Returns
|
|
2521
|
+
-------
|
|
2522
|
+
lines : list of `.lines.Line2D`
|
|
2523
|
+
The radial gridlines.
|
|
2524
|
+
|
|
2525
|
+
labels : list of `.text.Text`
|
|
2526
|
+
The tick labels.
|
|
2527
|
+
|
|
2528
|
+
Other Parameters
|
|
2529
|
+
----------------
|
|
2530
|
+
**kwargs
|
|
2531
|
+
*kwargs* are optional `.Text` properties for the labels.
|
|
2532
|
+
|
|
2533
|
+
See Also
|
|
2534
|
+
--------
|
|
2535
|
+
.pyplot.thetagrids
|
|
2536
|
+
.projections.polar.PolarAxes.set_rgrids
|
|
2537
|
+
.Axis.get_gridlines
|
|
2538
|
+
.Axis.get_ticklabels
|
|
2539
|
+
|
|
2540
|
+
Examples
|
|
2541
|
+
--------
|
|
2542
|
+
::
|
|
2543
|
+
|
|
2544
|
+
# set the locations of the radial gridlines
|
|
2545
|
+
lines, labels = rgrids( (0.25, 0.5, 1.0) )
|
|
2546
|
+
|
|
2547
|
+
# set the locations and labels of the radial gridlines
|
|
2548
|
+
lines, labels = rgrids( (0.25, 0.5, 1.0), ('Tom', 'Dick', 'Harry' ))
|
|
2549
|
+
"""
|
|
2550
|
+
ax = gca()
|
|
2551
|
+
from matplotlib_rs.projections import PolarAxes
|
|
2552
|
+
if not isinstance(ax, PolarAxes):
|
|
2553
|
+
raise RuntimeError('rgrids only defined for polar Axes')
|
|
2554
|
+
if all(p is None for p in [radii, labels, angle, fmt]) and not kwargs:
|
|
2555
|
+
lines_out: list[Line2D] = ax.yaxis.get_gridlines()
|
|
2556
|
+
labels_out: list[Text] = ax.yaxis.get_ticklabels()
|
|
2557
|
+
elif radii is None:
|
|
2558
|
+
raise TypeError("'radii' cannot be None when other parameters are passed")
|
|
2559
|
+
else:
|
|
2560
|
+
lines_out, labels_out = ax.set_rgrids(
|
|
2561
|
+
radii, labels=labels, angle=angle, fmt=fmt, **kwargs)
|
|
2562
|
+
return lines_out, labels_out
|
|
2563
|
+
|
|
2564
|
+
|
|
2565
|
+
def thetagrids(
|
|
2566
|
+
angles: ArrayLike | None = None,
|
|
2567
|
+
labels: Sequence[str | Text] | None = None,
|
|
2568
|
+
fmt: str | None = None,
|
|
2569
|
+
**kwargs
|
|
2570
|
+
) -> tuple[list[Line2D], list[Text]]:
|
|
2571
|
+
"""
|
|
2572
|
+
Get or set the theta gridlines on the current polar plot.
|
|
2573
|
+
|
|
2574
|
+
Call signatures::
|
|
2575
|
+
|
|
2576
|
+
lines, labels = thetagrids()
|
|
2577
|
+
lines, labels = thetagrids(angles, labels=None, fmt=None, **kwargs)
|
|
2578
|
+
|
|
2579
|
+
When called with no arguments, `.thetagrids` simply returns the tuple
|
|
2580
|
+
(*lines*, *labels*). When called with arguments, the labels will
|
|
2581
|
+
appear at the specified angles.
|
|
2582
|
+
|
|
2583
|
+
Parameters
|
|
2584
|
+
----------
|
|
2585
|
+
angles : tuple with floats, degrees
|
|
2586
|
+
The angles of the theta gridlines.
|
|
2587
|
+
|
|
2588
|
+
labels : tuple with strings or None
|
|
2589
|
+
The labels to use at each radial gridline. The
|
|
2590
|
+
`.projections.polar.ThetaFormatter` will be used if None.
|
|
2591
|
+
|
|
2592
|
+
fmt : str or None
|
|
2593
|
+
Format string used in `matplotlib.ticker.FormatStrFormatter`.
|
|
2594
|
+
For example '%f'. Note that the angle in radians will be used.
|
|
2595
|
+
|
|
2596
|
+
Returns
|
|
2597
|
+
-------
|
|
2598
|
+
lines : list of `.lines.Line2D`
|
|
2599
|
+
The theta gridlines.
|
|
2600
|
+
|
|
2601
|
+
labels : list of `.text.Text`
|
|
2602
|
+
The tick labels.
|
|
2603
|
+
|
|
2604
|
+
Other Parameters
|
|
2605
|
+
----------------
|
|
2606
|
+
**kwargs
|
|
2607
|
+
*kwargs* are optional `.Text` properties for the labels.
|
|
2608
|
+
|
|
2609
|
+
See Also
|
|
2610
|
+
--------
|
|
2611
|
+
.pyplot.rgrids
|
|
2612
|
+
.projections.polar.PolarAxes.set_thetagrids
|
|
2613
|
+
.Axis.get_gridlines
|
|
2614
|
+
.Axis.get_ticklabels
|
|
2615
|
+
|
|
2616
|
+
Examples
|
|
2617
|
+
--------
|
|
2618
|
+
::
|
|
2619
|
+
|
|
2620
|
+
# set the locations of the angular gridlines
|
|
2621
|
+
lines, labels = thetagrids(range(45, 360, 90))
|
|
2622
|
+
|
|
2623
|
+
# set the locations and labels of the angular gridlines
|
|
2624
|
+
lines, labels = thetagrids(range(45, 360, 90), ('NE', 'NW', 'SW', 'SE'))
|
|
2625
|
+
"""
|
|
2626
|
+
ax = gca()
|
|
2627
|
+
from matplotlib_rs.projections import PolarAxes
|
|
2628
|
+
if not isinstance(ax, PolarAxes):
|
|
2629
|
+
raise RuntimeError('thetagrids only defined for polar Axes')
|
|
2630
|
+
if all(param is None for param in [angles, labels, fmt]) and not kwargs:
|
|
2631
|
+
lines_out: list[Line2D] = ax.xaxis.get_ticklines()
|
|
2632
|
+
labels_out: list[Text] = ax.xaxis.get_ticklabels()
|
|
2633
|
+
elif angles is None:
|
|
2634
|
+
raise TypeError("'angles' cannot be None when other parameters are passed")
|
|
2635
|
+
else:
|
|
2636
|
+
lines_out, labels_out = ax.set_thetagrids(angles,
|
|
2637
|
+
labels=labels, fmt=fmt,
|
|
2638
|
+
**kwargs)
|
|
2639
|
+
return lines_out, labels_out
|
|
2640
|
+
|
|
2641
|
+
|
|
2642
|
+
@_api.deprecated("3.7", pending=True)
|
|
2643
|
+
def get_plot_commands() -> list[str]:
|
|
2644
|
+
"""
|
|
2645
|
+
Get a sorted list of all of the plotting commands.
|
|
2646
|
+
"""
|
|
2647
|
+
NON_PLOT_COMMANDS = {
|
|
2648
|
+
'connect', 'disconnect', 'get_current_fig_manager', 'ginput',
|
|
2649
|
+
'new_figure_manager', 'waitforbuttonpress'}
|
|
2650
|
+
return [name for name in _get_pyplot_commands()
|
|
2651
|
+
if name not in NON_PLOT_COMMANDS]
|
|
2652
|
+
|
|
2653
|
+
|
|
2654
|
+
def _get_pyplot_commands() -> list[str]:
|
|
2655
|
+
# This works by searching for all functions in this module and removing
|
|
2656
|
+
# a few hard-coded exclusions, as well as all of the colormap-setting
|
|
2657
|
+
# functions, and anything marked as private with a preceding underscore.
|
|
2658
|
+
exclude = {'colormaps', 'colors', 'get_plot_commands', *colormaps}
|
|
2659
|
+
this_module = inspect.getmodule(get_plot_commands)
|
|
2660
|
+
return sorted(
|
|
2661
|
+
name for name, obj in globals().items()
|
|
2662
|
+
if not name.startswith('_') and name not in exclude
|
|
2663
|
+
and inspect.isfunction(obj)
|
|
2664
|
+
and inspect.getmodule(obj) is this_module)
|
|
2665
|
+
|
|
2666
|
+
|
|
2667
|
+
## Plotting part 1: manually generated functions and wrappers ##
|
|
2668
|
+
|
|
2669
|
+
|
|
2670
|
+
@_copy_docstring_and_deprecators(Figure.colorbar)
|
|
2671
|
+
def colorbar(
|
|
2672
|
+
mappable: ScalarMappable | ColorizingArtist | None = None,
|
|
2673
|
+
cax: matplotlib.axes.Axes | None = None,
|
|
2674
|
+
ax: matplotlib.axes.Axes | Iterable[matplotlib.axes.Axes] | None = None,
|
|
2675
|
+
**kwargs
|
|
2676
|
+
) -> Colorbar:
|
|
2677
|
+
if mappable is None:
|
|
2678
|
+
mappable = gci()
|
|
2679
|
+
if mappable is None:
|
|
2680
|
+
raise RuntimeError('No mappable was found to use for colorbar '
|
|
2681
|
+
'creation. First define a mappable such as '
|
|
2682
|
+
'an image (with imshow) or a contour set ('
|
|
2683
|
+
'with contourf).')
|
|
2684
|
+
ret = gcf().colorbar(mappable, cax=cax, ax=ax, **kwargs)
|
|
2685
|
+
return ret
|
|
2686
|
+
|
|
2687
|
+
|
|
2688
|
+
def clim(vmin: float | None = None, vmax: float | None = None) -> None:
|
|
2689
|
+
"""
|
|
2690
|
+
Set the color limits of the current image.
|
|
2691
|
+
|
|
2692
|
+
If either *vmin* or *vmax* is None, the image min/max respectively
|
|
2693
|
+
will be used for color scaling.
|
|
2694
|
+
|
|
2695
|
+
If you want to set the clim of multiple images, use
|
|
2696
|
+
`~.ScalarMappable.set_clim` on every image, for example::
|
|
2697
|
+
|
|
2698
|
+
for im in gca().get_images():
|
|
2699
|
+
im.set_clim(0, 0.5)
|
|
2700
|
+
|
|
2701
|
+
"""
|
|
2702
|
+
im = gci()
|
|
2703
|
+
if im is None:
|
|
2704
|
+
raise RuntimeError('You must first define an image, e.g., with imshow')
|
|
2705
|
+
|
|
2706
|
+
im.set_clim(vmin, vmax)
|
|
2707
|
+
|
|
2708
|
+
|
|
2709
|
+
def get_cmap(name: Colormap | str | None = None, lut: int | None = None) -> Colormap:
|
|
2710
|
+
"""
|
|
2711
|
+
Get a colormap instance, defaulting to rc values if *name* is None.
|
|
2712
|
+
|
|
2713
|
+
Parameters
|
|
2714
|
+
----------
|
|
2715
|
+
name : `~matplotlib.colors.Colormap` or str or None, default: None
|
|
2716
|
+
If a `.Colormap` instance, it will be returned. Otherwise, the name of
|
|
2717
|
+
a colormap known to Matplotlib, which will be resampled by *lut*. The
|
|
2718
|
+
default, None, means :rc:`image.cmap`.
|
|
2719
|
+
lut : int or None, default: None
|
|
2720
|
+
If *name* is not already a Colormap instance and *lut* is not None, the
|
|
2721
|
+
colormap will be resampled to have *lut* entries in the lookup table.
|
|
2722
|
+
|
|
2723
|
+
Returns
|
|
2724
|
+
-------
|
|
2725
|
+
Colormap
|
|
2726
|
+
"""
|
|
2727
|
+
if name is None:
|
|
2728
|
+
name = rcParams['image.cmap']
|
|
2729
|
+
if isinstance(name, Colormap):
|
|
2730
|
+
return name
|
|
2731
|
+
_api.check_in_list(sorted(_colormaps), name=name)
|
|
2732
|
+
if lut is None:
|
|
2733
|
+
return _colormaps[name]
|
|
2734
|
+
else:
|
|
2735
|
+
return _colormaps[name].resampled(lut)
|
|
2736
|
+
|
|
2737
|
+
|
|
2738
|
+
def set_cmap(cmap: Colormap | str) -> None:
|
|
2739
|
+
"""
|
|
2740
|
+
Set the default colormap, and applies it to the current image if any.
|
|
2741
|
+
|
|
2742
|
+
Parameters
|
|
2743
|
+
----------
|
|
2744
|
+
cmap : `~matplotlib.colors.Colormap` or str
|
|
2745
|
+
A colormap instance or the name of a registered colormap.
|
|
2746
|
+
|
|
2747
|
+
See Also
|
|
2748
|
+
--------
|
|
2749
|
+
colormaps
|
|
2750
|
+
get_cmap
|
|
2751
|
+
"""
|
|
2752
|
+
cmap = get_cmap(cmap)
|
|
2753
|
+
|
|
2754
|
+
rc('image', cmap=cmap.name)
|
|
2755
|
+
im = gci()
|
|
2756
|
+
|
|
2757
|
+
if im is not None:
|
|
2758
|
+
im.set_cmap(cmap)
|
|
2759
|
+
|
|
2760
|
+
|
|
2761
|
+
@_copy_docstring_and_deprecators(matplotlib.image.imread)
|
|
2762
|
+
def imread(
|
|
2763
|
+
fname: str | pathlib.Path | BinaryIO, format: str | None = None
|
|
2764
|
+
) -> np.ndarray:
|
|
2765
|
+
return matplotlib.image.imread(fname, format)
|
|
2766
|
+
|
|
2767
|
+
|
|
2768
|
+
@_copy_docstring_and_deprecators(matplotlib.image.imsave)
|
|
2769
|
+
def imsave(
|
|
2770
|
+
fname: str | os.PathLike | BinaryIO, arr: ArrayLike, **kwargs
|
|
2771
|
+
) -> None:
|
|
2772
|
+
matplotlib.image.imsave(fname, arr, **kwargs)
|
|
2773
|
+
|
|
2774
|
+
|
|
2775
|
+
def matshow(A: ArrayLike, fignum: None | int = None, **kwargs) -> AxesImage:
|
|
2776
|
+
"""
|
|
2777
|
+
Display a 2D array as a matrix in a new figure window.
|
|
2778
|
+
|
|
2779
|
+
The origin is set at the upper left hand corner.
|
|
2780
|
+
The indexing is ``(row, column)`` so that the first index runs vertically
|
|
2781
|
+
and the second index runs horizontally in the figure:
|
|
2782
|
+
|
|
2783
|
+
.. code-block:: none
|
|
2784
|
+
|
|
2785
|
+
A[0, 0] ⋯ A[0, M-1]
|
|
2786
|
+
⋮ ⋮
|
|
2787
|
+
A[N-1, 0] ⋯ A[N-1, M-1]
|
|
2788
|
+
|
|
2789
|
+
The aspect ratio of the figure window is that of the array,
|
|
2790
|
+
unless this would make an excessively short or narrow figure.
|
|
2791
|
+
|
|
2792
|
+
Tick labels for the xaxis are placed on top.
|
|
2793
|
+
|
|
2794
|
+
Parameters
|
|
2795
|
+
----------
|
|
2796
|
+
A : 2D array-like
|
|
2797
|
+
The matrix to be displayed.
|
|
2798
|
+
|
|
2799
|
+
fignum : None or int
|
|
2800
|
+
If *None*, create a new, appropriately sized figure window.
|
|
2801
|
+
|
|
2802
|
+
If 0, use the current Axes (creating one if there is none, without ever
|
|
2803
|
+
adjusting the figure size).
|
|
2804
|
+
|
|
2805
|
+
Otherwise, create a new Axes on the figure with the given number
|
|
2806
|
+
(creating it at the appropriate size if it does not exist, but not
|
|
2807
|
+
adjusting the figure size otherwise). Note that this will be drawn on
|
|
2808
|
+
top of any preexisting Axes on the figure.
|
|
2809
|
+
|
|
2810
|
+
Returns
|
|
2811
|
+
-------
|
|
2812
|
+
`~matplotlib.image.AxesImage`
|
|
2813
|
+
|
|
2814
|
+
Other Parameters
|
|
2815
|
+
----------------
|
|
2816
|
+
**kwargs : `~matplotlib.axes.Axes.imshow` arguments
|
|
2817
|
+
|
|
2818
|
+
"""
|
|
2819
|
+
A = np.asanyarray(A)
|
|
2820
|
+
if fignum == 0:
|
|
2821
|
+
ax = gca()
|
|
2822
|
+
else:
|
|
2823
|
+
if fignum is not None and fignum_exists(fignum):
|
|
2824
|
+
# Do not try to set a figure size.
|
|
2825
|
+
figsize = None
|
|
2826
|
+
else:
|
|
2827
|
+
# Extract actual aspect ratio of array and make appropriately sized figure.
|
|
2828
|
+
figsize = figaspect(A)
|
|
2829
|
+
fig = figure(fignum, figsize=figsize)
|
|
2830
|
+
ax = fig.add_axes((0.15, 0.09, 0.775, 0.775))
|
|
2831
|
+
im = ax.matshow(A, **kwargs)
|
|
2832
|
+
sci(im)
|
|
2833
|
+
return im
|
|
2834
|
+
|
|
2835
|
+
|
|
2836
|
+
def polar(*args, **kwargs) -> list[Line2D]:
|
|
2837
|
+
"""
|
|
2838
|
+
Make a polar plot.
|
|
2839
|
+
|
|
2840
|
+
call signature::
|
|
2841
|
+
|
|
2842
|
+
polar(theta, r, [fmt], **kwargs)
|
|
2843
|
+
|
|
2844
|
+
This is a convenience wrapper around `.pyplot.plot`. It ensures that the
|
|
2845
|
+
current Axes is polar (or creates one if needed) and then passes all parameters
|
|
2846
|
+
to ``.pyplot.plot``.
|
|
2847
|
+
|
|
2848
|
+
.. note::
|
|
2849
|
+
When making polar plots using the :ref:`pyplot API <pyplot_interface>`,
|
|
2850
|
+
``polar()`` should typically be the first command because that makes sure
|
|
2851
|
+
a polar Axes is created. Using other commands such as ``plt.title()``
|
|
2852
|
+
before this can lead to the implicit creation of a rectangular Axes, in which
|
|
2853
|
+
case a subsequent ``polar()`` call will fail.
|
|
2854
|
+
"""
|
|
2855
|
+
# If an axis already exists, check if it has a polar projection
|
|
2856
|
+
if gcf().get_axes():
|
|
2857
|
+
ax = gca()
|
|
2858
|
+
from matplotlib_rs.projections import PolarAxes
|
|
2859
|
+
if not isinstance(ax, PolarAxes):
|
|
2860
|
+
_api.warn_deprecated(
|
|
2861
|
+
"3.10",
|
|
2862
|
+
message="There exists a non-polar current Axes. Therefore, the "
|
|
2863
|
+
"resulting plot from 'polar()' is non-polar. You likely "
|
|
2864
|
+
"should call 'polar()' before any other pyplot plotting "
|
|
2865
|
+
"commands. "
|
|
2866
|
+
"Support for this scenario is deprecated in %(since)s and "
|
|
2867
|
+
"will raise an error in %(removal)s"
|
|
2868
|
+
)
|
|
2869
|
+
else:
|
|
2870
|
+
ax = axes(projection="polar")
|
|
2871
|
+
return ax.plot(*args, **kwargs)
|
|
2872
|
+
|
|
2873
|
+
|
|
2874
|
+
# If rcParams['backend_fallback'] is true, and an interactive backend is
|
|
2875
|
+
# requested, ignore rcParams['backend'] and force selection of a backend that
|
|
2876
|
+
# is compatible with the current running interactive framework.
|
|
2877
|
+
if rcParams["backend_fallback"]:
|
|
2878
|
+
requested_backend = rcParams._get_backend_or_none() # type: ignore[attr-defined]
|
|
2879
|
+
requested_backend = None if requested_backend is None else requested_backend.lower()
|
|
2880
|
+
available_backends = backend_registry.list_builtin(BackendFilter.INTERACTIVE)
|
|
2881
|
+
if (
|
|
2882
|
+
requested_backend in (set(available_backends) - {'webagg', 'nbagg'})
|
|
2883
|
+
and cbook._get_running_interactive_framework()
|
|
2884
|
+
):
|
|
2885
|
+
rcParams._set("backend", rcsetup._auto_backend_sentinel)
|
|
2886
|
+
|
|
2887
|
+
# fmt: on
|
|
2888
|
+
|
|
2889
|
+
################# REMAINING CONTENT GENERATED BY boilerplate.py ##############
|
|
2890
|
+
|
|
2891
|
+
|
|
2892
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
2893
|
+
@_copy_docstring_and_deprecators(Figure.figimage)
|
|
2894
|
+
def figimage(
|
|
2895
|
+
X: ArrayLike,
|
|
2896
|
+
xo: int = 0,
|
|
2897
|
+
yo: int = 0,
|
|
2898
|
+
alpha: float | None = None,
|
|
2899
|
+
norm: str | Normalize | None = None,
|
|
2900
|
+
cmap: str | Colormap | None = None,
|
|
2901
|
+
vmin: float | None = None,
|
|
2902
|
+
vmax: float | None = None,
|
|
2903
|
+
origin: Literal["upper", "lower"] | None = None,
|
|
2904
|
+
resize: bool = False,
|
|
2905
|
+
*,
|
|
2906
|
+
colorizer: Colorizer | None = None,
|
|
2907
|
+
**kwargs,
|
|
2908
|
+
) -> FigureImage:
|
|
2909
|
+
return gcf().figimage(
|
|
2910
|
+
X,
|
|
2911
|
+
xo=xo,
|
|
2912
|
+
yo=yo,
|
|
2913
|
+
alpha=alpha,
|
|
2914
|
+
norm=norm,
|
|
2915
|
+
cmap=cmap,
|
|
2916
|
+
vmin=vmin,
|
|
2917
|
+
vmax=vmax,
|
|
2918
|
+
origin=origin,
|
|
2919
|
+
resize=resize,
|
|
2920
|
+
colorizer=colorizer,
|
|
2921
|
+
**kwargs,
|
|
2922
|
+
)
|
|
2923
|
+
|
|
2924
|
+
|
|
2925
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
2926
|
+
@_copy_docstring_and_deprecators(Figure.text)
|
|
2927
|
+
def figtext(
|
|
2928
|
+
x: float, y: float, s: str, fontdict: dict[str, Any] | None = None, **kwargs
|
|
2929
|
+
) -> Text:
|
|
2930
|
+
return gcf().text(x, y, s, fontdict=fontdict, **kwargs)
|
|
2931
|
+
|
|
2932
|
+
|
|
2933
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
2934
|
+
@_copy_docstring_and_deprecators(Figure.gca)
|
|
2935
|
+
def gca() -> Axes:
|
|
2936
|
+
return gcf().gca()
|
|
2937
|
+
|
|
2938
|
+
|
|
2939
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
2940
|
+
@_copy_docstring_and_deprecators(Figure._gci)
|
|
2941
|
+
def gci() -> ColorizingArtist | None:
|
|
2942
|
+
return gcf()._gci()
|
|
2943
|
+
|
|
2944
|
+
|
|
2945
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
2946
|
+
@_copy_docstring_and_deprecators(Figure.ginput)
|
|
2947
|
+
def ginput(
|
|
2948
|
+
n: int = 1,
|
|
2949
|
+
timeout: float = 30,
|
|
2950
|
+
show_clicks: bool = True,
|
|
2951
|
+
mouse_add: MouseButton = MouseButton.LEFT,
|
|
2952
|
+
mouse_pop: MouseButton = MouseButton.RIGHT,
|
|
2953
|
+
mouse_stop: MouseButton = MouseButton.MIDDLE,
|
|
2954
|
+
) -> list[tuple[int, int]]:
|
|
2955
|
+
return gcf().ginput(
|
|
2956
|
+
n=n,
|
|
2957
|
+
timeout=timeout,
|
|
2958
|
+
show_clicks=show_clicks,
|
|
2959
|
+
mouse_add=mouse_add,
|
|
2960
|
+
mouse_pop=mouse_pop,
|
|
2961
|
+
mouse_stop=mouse_stop,
|
|
2962
|
+
)
|
|
2963
|
+
|
|
2964
|
+
|
|
2965
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
2966
|
+
@_copy_docstring_and_deprecators(Figure.subplots_adjust)
|
|
2967
|
+
def subplots_adjust(
|
|
2968
|
+
left: float | None = None,
|
|
2969
|
+
bottom: float | None = None,
|
|
2970
|
+
right: float | None = None,
|
|
2971
|
+
top: float | None = None,
|
|
2972
|
+
wspace: float | None = None,
|
|
2973
|
+
hspace: float | None = None,
|
|
2974
|
+
) -> None:
|
|
2975
|
+
gcf().subplots_adjust(
|
|
2976
|
+
left=left, bottom=bottom, right=right, top=top, wspace=wspace, hspace=hspace
|
|
2977
|
+
)
|
|
2978
|
+
|
|
2979
|
+
|
|
2980
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
2981
|
+
@_copy_docstring_and_deprecators(Figure.suptitle)
|
|
2982
|
+
def suptitle(t: str, **kwargs) -> Text:
|
|
2983
|
+
return gcf().suptitle(t, **kwargs)
|
|
2984
|
+
|
|
2985
|
+
|
|
2986
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
2987
|
+
@_copy_docstring_and_deprecators(Figure.tight_layout)
|
|
2988
|
+
def tight_layout(
|
|
2989
|
+
*,
|
|
2990
|
+
pad: float = 1.08,
|
|
2991
|
+
h_pad: float | None = None,
|
|
2992
|
+
w_pad: float | None = None,
|
|
2993
|
+
rect: tuple[float, float, float, float] | None = None,
|
|
2994
|
+
) -> None:
|
|
2995
|
+
gcf().tight_layout(pad=pad, h_pad=h_pad, w_pad=w_pad, rect=rect)
|
|
2996
|
+
|
|
2997
|
+
|
|
2998
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
2999
|
+
@_copy_docstring_and_deprecators(Figure.waitforbuttonpress)
|
|
3000
|
+
def waitforbuttonpress(timeout: float = -1) -> None | bool:
|
|
3001
|
+
return gcf().waitforbuttonpress(timeout=timeout)
|
|
3002
|
+
|
|
3003
|
+
|
|
3004
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
3005
|
+
@_copy_docstring_and_deprecators(Axes.acorr)
|
|
3006
|
+
def acorr(
|
|
3007
|
+
x: ArrayLike, *, data: DataParamType = None, **kwargs
|
|
3008
|
+
) -> tuple[np.ndarray, np.ndarray, LineCollection | Line2D, Line2D | None]:
|
|
3009
|
+
return gca().acorr(x, **({"data": data} if data is not None else {}), **kwargs)
|
|
3010
|
+
|
|
3011
|
+
|
|
3012
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
3013
|
+
@_copy_docstring_and_deprecators(Axes.angle_spectrum)
|
|
3014
|
+
def angle_spectrum(
|
|
3015
|
+
x: ArrayLike,
|
|
3016
|
+
Fs: float | None = None,
|
|
3017
|
+
Fc: int | None = None,
|
|
3018
|
+
window: Callable[[ArrayLike], ArrayLike] | ArrayLike | None = None,
|
|
3019
|
+
pad_to: int | None = None,
|
|
3020
|
+
sides: Literal["default", "onesided", "twosided"] | None = None,
|
|
3021
|
+
*,
|
|
3022
|
+
data: DataParamType = None,
|
|
3023
|
+
**kwargs,
|
|
3024
|
+
) -> tuple[np.ndarray, np.ndarray, Line2D]:
|
|
3025
|
+
return gca().angle_spectrum(
|
|
3026
|
+
x,
|
|
3027
|
+
Fs=Fs,
|
|
3028
|
+
Fc=Fc,
|
|
3029
|
+
window=window,
|
|
3030
|
+
pad_to=pad_to,
|
|
3031
|
+
sides=sides,
|
|
3032
|
+
**({"data": data} if data is not None else {}),
|
|
3033
|
+
**kwargs,
|
|
3034
|
+
)
|
|
3035
|
+
|
|
3036
|
+
|
|
3037
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
3038
|
+
@_copy_docstring_and_deprecators(Axes.annotate)
|
|
3039
|
+
def annotate(
|
|
3040
|
+
text: str,
|
|
3041
|
+
xy: tuple[Any, Any],
|
|
3042
|
+
xytext: tuple[Any, Any] | None = None,
|
|
3043
|
+
xycoords: CoordsType = "data",
|
|
3044
|
+
textcoords: CoordsType | None = None,
|
|
3045
|
+
arrowprops: dict[str, Any] | None = None,
|
|
3046
|
+
annotation_clip: bool | None = None,
|
|
3047
|
+
**kwargs,
|
|
3048
|
+
) -> Annotation:
|
|
3049
|
+
return gca().annotate(
|
|
3050
|
+
text,
|
|
3051
|
+
xy,
|
|
3052
|
+
xytext=xytext,
|
|
3053
|
+
xycoords=xycoords,
|
|
3054
|
+
textcoords=textcoords,
|
|
3055
|
+
arrowprops=arrowprops,
|
|
3056
|
+
annotation_clip=annotation_clip,
|
|
3057
|
+
**kwargs,
|
|
3058
|
+
)
|
|
3059
|
+
|
|
3060
|
+
|
|
3061
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
3062
|
+
@_copy_docstring_and_deprecators(Axes.arrow)
|
|
3063
|
+
def arrow(x: float, y: float, dx: float, dy: float, **kwargs) -> FancyArrow:
|
|
3064
|
+
return gca().arrow(x, y, dx, dy, **kwargs)
|
|
3065
|
+
|
|
3066
|
+
|
|
3067
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
3068
|
+
@_copy_docstring_and_deprecators(Axes.autoscale)
|
|
3069
|
+
def autoscale(
|
|
3070
|
+
enable: bool = True,
|
|
3071
|
+
axis: Literal["both", "x", "y"] = "both",
|
|
3072
|
+
tight: bool | None = None,
|
|
3073
|
+
) -> None:
|
|
3074
|
+
gca().autoscale(enable=enable, axis=axis, tight=tight)
|
|
3075
|
+
|
|
3076
|
+
|
|
3077
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
3078
|
+
@_copy_docstring_and_deprecators(Axes.axhline)
|
|
3079
|
+
def axhline(y: float = 0, xmin: float = 0, xmax: float = 1, **kwargs) -> Line2D:
|
|
3080
|
+
return gca().axhline(y=y, xmin=xmin, xmax=xmax, **kwargs)
|
|
3081
|
+
|
|
3082
|
+
|
|
3083
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
3084
|
+
@_copy_docstring_and_deprecators(Axes.axhspan)
|
|
3085
|
+
def axhspan(
|
|
3086
|
+
ymin: float, ymax: float, xmin: float = 0, xmax: float = 1, **kwargs
|
|
3087
|
+
) -> Rectangle:
|
|
3088
|
+
return gca().axhspan(ymin, ymax, xmin=xmin, xmax=xmax, **kwargs)
|
|
3089
|
+
|
|
3090
|
+
|
|
3091
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
3092
|
+
@_copy_docstring_and_deprecators(Axes.axis)
|
|
3093
|
+
def axis(
|
|
3094
|
+
arg: tuple[float, float, float, float] | bool | str | None = None,
|
|
3095
|
+
/,
|
|
3096
|
+
*,
|
|
3097
|
+
emit: bool = True,
|
|
3098
|
+
**kwargs,
|
|
3099
|
+
) -> tuple[float, float, float, float]:
|
|
3100
|
+
return gca().axis(arg, emit=emit, **kwargs)
|
|
3101
|
+
|
|
3102
|
+
|
|
3103
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
3104
|
+
@_copy_docstring_and_deprecators(Axes.axline)
|
|
3105
|
+
def axline(
|
|
3106
|
+
xy1: tuple[float, float],
|
|
3107
|
+
xy2: tuple[float, float] | None = None,
|
|
3108
|
+
*,
|
|
3109
|
+
slope: float | None = None,
|
|
3110
|
+
**kwargs,
|
|
3111
|
+
) -> AxLine:
|
|
3112
|
+
return gca().axline(xy1, xy2=xy2, slope=slope, **kwargs)
|
|
3113
|
+
|
|
3114
|
+
|
|
3115
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
3116
|
+
@_copy_docstring_and_deprecators(Axes.axvline)
|
|
3117
|
+
def axvline(x: float = 0, ymin: float = 0, ymax: float = 1, **kwargs) -> Line2D:
|
|
3118
|
+
return gca().axvline(x=x, ymin=ymin, ymax=ymax, **kwargs)
|
|
3119
|
+
|
|
3120
|
+
|
|
3121
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
3122
|
+
@_copy_docstring_and_deprecators(Axes.axvspan)
|
|
3123
|
+
def axvspan(
|
|
3124
|
+
xmin: float, xmax: float, ymin: float = 0, ymax: float = 1, **kwargs
|
|
3125
|
+
) -> Rectangle:
|
|
3126
|
+
return gca().axvspan(xmin, xmax, ymin=ymin, ymax=ymax, **kwargs)
|
|
3127
|
+
|
|
3128
|
+
|
|
3129
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
3130
|
+
@_copy_docstring_and_deprecators(Axes.bar)
|
|
3131
|
+
def bar(
|
|
3132
|
+
x: float | ArrayLike,
|
|
3133
|
+
height: float | ArrayLike,
|
|
3134
|
+
width: float | ArrayLike = 0.8,
|
|
3135
|
+
bottom: float | ArrayLike | None = None,
|
|
3136
|
+
*,
|
|
3137
|
+
align: Literal["center", "edge"] = "center",
|
|
3138
|
+
data: DataParamType = None,
|
|
3139
|
+
**kwargs,
|
|
3140
|
+
) -> BarContainer:
|
|
3141
|
+
return gca().bar(
|
|
3142
|
+
x,
|
|
3143
|
+
height,
|
|
3144
|
+
width=width,
|
|
3145
|
+
bottom=bottom,
|
|
3146
|
+
align=align,
|
|
3147
|
+
**({"data": data} if data is not None else {}),
|
|
3148
|
+
**kwargs,
|
|
3149
|
+
)
|
|
3150
|
+
|
|
3151
|
+
|
|
3152
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
3153
|
+
@_copy_docstring_and_deprecators(Axes.barbs)
|
|
3154
|
+
def barbs(*args, data: DataParamType = None, **kwargs) -> Barbs:
|
|
3155
|
+
return gca().barbs(*args, **({"data": data} if data is not None else {}), **kwargs)
|
|
3156
|
+
|
|
3157
|
+
|
|
3158
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
3159
|
+
@_copy_docstring_and_deprecators(Axes.barh)
|
|
3160
|
+
def barh(
|
|
3161
|
+
y: float | ArrayLike,
|
|
3162
|
+
width: float | ArrayLike,
|
|
3163
|
+
height: float | ArrayLike = 0.8,
|
|
3164
|
+
left: float | ArrayLike | None = None,
|
|
3165
|
+
*,
|
|
3166
|
+
align: Literal["center", "edge"] = "center",
|
|
3167
|
+
data: DataParamType = None,
|
|
3168
|
+
**kwargs,
|
|
3169
|
+
) -> BarContainer:
|
|
3170
|
+
return gca().barh(
|
|
3171
|
+
y,
|
|
3172
|
+
width,
|
|
3173
|
+
height=height,
|
|
3174
|
+
left=left,
|
|
3175
|
+
align=align,
|
|
3176
|
+
**({"data": data} if data is not None else {}),
|
|
3177
|
+
**kwargs,
|
|
3178
|
+
)
|
|
3179
|
+
|
|
3180
|
+
|
|
3181
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
3182
|
+
@_copy_docstring_and_deprecators(Axes.bar_label)
|
|
3183
|
+
def bar_label(
|
|
3184
|
+
container: BarContainer,
|
|
3185
|
+
labels: ArrayLike | None = None,
|
|
3186
|
+
*,
|
|
3187
|
+
fmt: str | Callable[[float], str] = "%g",
|
|
3188
|
+
label_type: Literal["center", "edge"] = "edge",
|
|
3189
|
+
padding: float | ArrayLike = 0,
|
|
3190
|
+
**kwargs,
|
|
3191
|
+
) -> list[Annotation]:
|
|
3192
|
+
return gca().bar_label(
|
|
3193
|
+
container,
|
|
3194
|
+
labels=labels,
|
|
3195
|
+
fmt=fmt,
|
|
3196
|
+
label_type=label_type,
|
|
3197
|
+
padding=padding,
|
|
3198
|
+
**kwargs,
|
|
3199
|
+
)
|
|
3200
|
+
|
|
3201
|
+
|
|
3202
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
3203
|
+
@_copy_docstring_and_deprecators(Axes.boxplot)
|
|
3204
|
+
def boxplot(
|
|
3205
|
+
x: ArrayLike | Sequence[ArrayLike],
|
|
3206
|
+
notch: bool | None = None,
|
|
3207
|
+
sym: str | None = None,
|
|
3208
|
+
vert: bool | None = None,
|
|
3209
|
+
orientation: Literal["vertical", "horizontal"] = "vertical",
|
|
3210
|
+
whis: float | tuple[float, float] | None = None,
|
|
3211
|
+
positions: ArrayLike | None = None,
|
|
3212
|
+
widths: float | ArrayLike | None = None,
|
|
3213
|
+
patch_artist: bool | None = None,
|
|
3214
|
+
bootstrap: int | None = None,
|
|
3215
|
+
usermedians: ArrayLike | None = None,
|
|
3216
|
+
conf_intervals: ArrayLike | None = None,
|
|
3217
|
+
meanline: bool | None = None,
|
|
3218
|
+
showmeans: bool | None = None,
|
|
3219
|
+
showcaps: bool | None = None,
|
|
3220
|
+
showbox: bool | None = None,
|
|
3221
|
+
showfliers: bool | None = None,
|
|
3222
|
+
boxprops: dict[str, Any] | None = None,
|
|
3223
|
+
tick_labels: Sequence[str] | None = None,
|
|
3224
|
+
flierprops: dict[str, Any] | None = None,
|
|
3225
|
+
medianprops: dict[str, Any] | None = None,
|
|
3226
|
+
meanprops: dict[str, Any] | None = None,
|
|
3227
|
+
capprops: dict[str, Any] | None = None,
|
|
3228
|
+
whiskerprops: dict[str, Any] | None = None,
|
|
3229
|
+
manage_ticks: bool = True,
|
|
3230
|
+
autorange: bool = False,
|
|
3231
|
+
zorder: float | None = None,
|
|
3232
|
+
capwidths: float | ArrayLike | None = None,
|
|
3233
|
+
label: Sequence[str] | None = None,
|
|
3234
|
+
*,
|
|
3235
|
+
data: DataParamType = None,
|
|
3236
|
+
) -> dict[str, Any]:
|
|
3237
|
+
return gca().boxplot(
|
|
3238
|
+
x,
|
|
3239
|
+
notch=notch,
|
|
3240
|
+
sym=sym,
|
|
3241
|
+
vert=vert,
|
|
3242
|
+
orientation=orientation,
|
|
3243
|
+
whis=whis,
|
|
3244
|
+
positions=positions,
|
|
3245
|
+
widths=widths,
|
|
3246
|
+
patch_artist=patch_artist,
|
|
3247
|
+
bootstrap=bootstrap,
|
|
3248
|
+
usermedians=usermedians,
|
|
3249
|
+
conf_intervals=conf_intervals,
|
|
3250
|
+
meanline=meanline,
|
|
3251
|
+
showmeans=showmeans,
|
|
3252
|
+
showcaps=showcaps,
|
|
3253
|
+
showbox=showbox,
|
|
3254
|
+
showfliers=showfliers,
|
|
3255
|
+
boxprops=boxprops,
|
|
3256
|
+
tick_labels=tick_labels,
|
|
3257
|
+
flierprops=flierprops,
|
|
3258
|
+
medianprops=medianprops,
|
|
3259
|
+
meanprops=meanprops,
|
|
3260
|
+
capprops=capprops,
|
|
3261
|
+
whiskerprops=whiskerprops,
|
|
3262
|
+
manage_ticks=manage_ticks,
|
|
3263
|
+
autorange=autorange,
|
|
3264
|
+
zorder=zorder,
|
|
3265
|
+
capwidths=capwidths,
|
|
3266
|
+
label=label,
|
|
3267
|
+
**({"data": data} if data is not None else {}),
|
|
3268
|
+
)
|
|
3269
|
+
|
|
3270
|
+
|
|
3271
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
3272
|
+
@_copy_docstring_and_deprecators(Axes.broken_barh)
|
|
3273
|
+
def broken_barh(
|
|
3274
|
+
xranges: Sequence[tuple[float, float]],
|
|
3275
|
+
yrange: tuple[float, float],
|
|
3276
|
+
align: Literal["bottom", "center", "top"] = "bottom",
|
|
3277
|
+
*,
|
|
3278
|
+
data: DataParamType = None,
|
|
3279
|
+
**kwargs,
|
|
3280
|
+
) -> PolyCollection:
|
|
3281
|
+
return gca().broken_barh(
|
|
3282
|
+
xranges,
|
|
3283
|
+
yrange,
|
|
3284
|
+
align=align,
|
|
3285
|
+
**({"data": data} if data is not None else {}),
|
|
3286
|
+
**kwargs,
|
|
3287
|
+
)
|
|
3288
|
+
|
|
3289
|
+
|
|
3290
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
3291
|
+
@_copy_docstring_and_deprecators(Axes.clabel)
|
|
3292
|
+
def clabel(CS: ContourSet, levels: ArrayLike | None = None, **kwargs) -> list[Text]:
|
|
3293
|
+
return gca().clabel(CS, levels=levels, **kwargs)
|
|
3294
|
+
|
|
3295
|
+
|
|
3296
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
3297
|
+
@_copy_docstring_and_deprecators(Axes.cohere)
|
|
3298
|
+
def cohere(
|
|
3299
|
+
x: ArrayLike,
|
|
3300
|
+
y: ArrayLike,
|
|
3301
|
+
NFFT: int = 256,
|
|
3302
|
+
Fs: float = 2,
|
|
3303
|
+
Fc: int = 0,
|
|
3304
|
+
detrend: (
|
|
3305
|
+
Literal["none", "mean", "linear"] | Callable[[ArrayLike], ArrayLike]
|
|
3306
|
+
) = mlab.detrend_none,
|
|
3307
|
+
window: Callable[[ArrayLike], ArrayLike] | ArrayLike = mlab.window_hanning,
|
|
3308
|
+
noverlap: int = 0,
|
|
3309
|
+
pad_to: int | None = None,
|
|
3310
|
+
sides: Literal["default", "onesided", "twosided"] = "default",
|
|
3311
|
+
scale_by_freq: bool | None = None,
|
|
3312
|
+
*,
|
|
3313
|
+
data: DataParamType = None,
|
|
3314
|
+
**kwargs,
|
|
3315
|
+
) -> tuple[np.ndarray, np.ndarray]:
|
|
3316
|
+
return gca().cohere(
|
|
3317
|
+
x,
|
|
3318
|
+
y,
|
|
3319
|
+
NFFT=NFFT,
|
|
3320
|
+
Fs=Fs,
|
|
3321
|
+
Fc=Fc,
|
|
3322
|
+
detrend=detrend,
|
|
3323
|
+
window=window,
|
|
3324
|
+
noverlap=noverlap,
|
|
3325
|
+
pad_to=pad_to,
|
|
3326
|
+
sides=sides,
|
|
3327
|
+
scale_by_freq=scale_by_freq,
|
|
3328
|
+
**({"data": data} if data is not None else {}),
|
|
3329
|
+
**kwargs,
|
|
3330
|
+
)
|
|
3331
|
+
|
|
3332
|
+
|
|
3333
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
3334
|
+
@_copy_docstring_and_deprecators(Axes.contour)
|
|
3335
|
+
def contour(*args, data: DataParamType = None, **kwargs) -> QuadContourSet:
|
|
3336
|
+
__ret = gca().contour(
|
|
3337
|
+
*args, **({"data": data} if data is not None else {}), **kwargs
|
|
3338
|
+
)
|
|
3339
|
+
if __ret._A is not None: # type: ignore[attr-defined]
|
|
3340
|
+
sci(__ret)
|
|
3341
|
+
return __ret
|
|
3342
|
+
|
|
3343
|
+
|
|
3344
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
3345
|
+
@_copy_docstring_and_deprecators(Axes.contourf)
|
|
3346
|
+
def contourf(*args, data: DataParamType = None, **kwargs) -> QuadContourSet:
|
|
3347
|
+
__ret = gca().contourf(
|
|
3348
|
+
*args, **({"data": data} if data is not None else {}), **kwargs
|
|
3349
|
+
)
|
|
3350
|
+
if __ret._A is not None: # type: ignore[attr-defined]
|
|
3351
|
+
sci(__ret)
|
|
3352
|
+
return __ret
|
|
3353
|
+
|
|
3354
|
+
|
|
3355
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
3356
|
+
@_copy_docstring_and_deprecators(Axes.csd)
|
|
3357
|
+
def csd(
|
|
3358
|
+
x: ArrayLike,
|
|
3359
|
+
y: ArrayLike,
|
|
3360
|
+
NFFT: int | None = None,
|
|
3361
|
+
Fs: float | None = None,
|
|
3362
|
+
Fc: int | None = None,
|
|
3363
|
+
detrend: (
|
|
3364
|
+
Literal["none", "mean", "linear"] | Callable[[ArrayLike], ArrayLike] | None
|
|
3365
|
+
) = None,
|
|
3366
|
+
window: Callable[[ArrayLike], ArrayLike] | ArrayLike | None = None,
|
|
3367
|
+
noverlap: int | None = None,
|
|
3368
|
+
pad_to: int | None = None,
|
|
3369
|
+
sides: Literal["default", "onesided", "twosided"] | None = None,
|
|
3370
|
+
scale_by_freq: bool | None = None,
|
|
3371
|
+
return_line: bool | None = None,
|
|
3372
|
+
*,
|
|
3373
|
+
data: DataParamType = None,
|
|
3374
|
+
**kwargs,
|
|
3375
|
+
) -> tuple[np.ndarray, np.ndarray] | tuple[np.ndarray, np.ndarray, Line2D]:
|
|
3376
|
+
return gca().csd(
|
|
3377
|
+
x,
|
|
3378
|
+
y,
|
|
3379
|
+
NFFT=NFFT,
|
|
3380
|
+
Fs=Fs,
|
|
3381
|
+
Fc=Fc,
|
|
3382
|
+
detrend=detrend,
|
|
3383
|
+
window=window,
|
|
3384
|
+
noverlap=noverlap,
|
|
3385
|
+
pad_to=pad_to,
|
|
3386
|
+
sides=sides,
|
|
3387
|
+
scale_by_freq=scale_by_freq,
|
|
3388
|
+
return_line=return_line,
|
|
3389
|
+
**({"data": data} if data is not None else {}),
|
|
3390
|
+
**kwargs,
|
|
3391
|
+
)
|
|
3392
|
+
|
|
3393
|
+
|
|
3394
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
3395
|
+
@_copy_docstring_and_deprecators(Axes.ecdf)
|
|
3396
|
+
def ecdf(
|
|
3397
|
+
x: ArrayLike,
|
|
3398
|
+
weights: ArrayLike | None = None,
|
|
3399
|
+
*,
|
|
3400
|
+
complementary: bool = False,
|
|
3401
|
+
orientation: Literal["vertical", "horizontal"] = "vertical",
|
|
3402
|
+
compress: bool = False,
|
|
3403
|
+
data: DataParamType = None,
|
|
3404
|
+
**kwargs,
|
|
3405
|
+
) -> Line2D:
|
|
3406
|
+
return gca().ecdf(
|
|
3407
|
+
x,
|
|
3408
|
+
weights=weights,
|
|
3409
|
+
complementary=complementary,
|
|
3410
|
+
orientation=orientation,
|
|
3411
|
+
compress=compress,
|
|
3412
|
+
**({"data": data} if data is not None else {}),
|
|
3413
|
+
**kwargs,
|
|
3414
|
+
)
|
|
3415
|
+
|
|
3416
|
+
|
|
3417
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
3418
|
+
@_copy_docstring_and_deprecators(Axes.errorbar)
|
|
3419
|
+
def errorbar(
|
|
3420
|
+
x: float | ArrayLike,
|
|
3421
|
+
y: float | ArrayLike,
|
|
3422
|
+
yerr: float | ArrayLike | None = None,
|
|
3423
|
+
xerr: float | ArrayLike | None = None,
|
|
3424
|
+
fmt: str = "",
|
|
3425
|
+
ecolor: ColorType | None = None,
|
|
3426
|
+
elinewidth: float | None = None,
|
|
3427
|
+
capsize: float | None = None,
|
|
3428
|
+
barsabove: bool = False,
|
|
3429
|
+
lolims: bool | ArrayLike = False,
|
|
3430
|
+
uplims: bool | ArrayLike = False,
|
|
3431
|
+
xlolims: bool | ArrayLike = False,
|
|
3432
|
+
xuplims: bool | ArrayLike = False,
|
|
3433
|
+
errorevery: int | tuple[int, int] = 1,
|
|
3434
|
+
capthick: float | None = None,
|
|
3435
|
+
elinestyle: LineStyleType | None = None,
|
|
3436
|
+
*,
|
|
3437
|
+
data: DataParamType = None,
|
|
3438
|
+
**kwargs,
|
|
3439
|
+
) -> ErrorbarContainer:
|
|
3440
|
+
return gca().errorbar(
|
|
3441
|
+
x,
|
|
3442
|
+
y,
|
|
3443
|
+
yerr=yerr,
|
|
3444
|
+
xerr=xerr,
|
|
3445
|
+
fmt=fmt,
|
|
3446
|
+
ecolor=ecolor,
|
|
3447
|
+
elinewidth=elinewidth,
|
|
3448
|
+
capsize=capsize,
|
|
3449
|
+
barsabove=barsabove,
|
|
3450
|
+
lolims=lolims,
|
|
3451
|
+
uplims=uplims,
|
|
3452
|
+
xlolims=xlolims,
|
|
3453
|
+
xuplims=xuplims,
|
|
3454
|
+
errorevery=errorevery,
|
|
3455
|
+
capthick=capthick,
|
|
3456
|
+
elinestyle=elinestyle,
|
|
3457
|
+
**({"data": data} if data is not None else {}),
|
|
3458
|
+
**kwargs,
|
|
3459
|
+
)
|
|
3460
|
+
|
|
3461
|
+
|
|
3462
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
3463
|
+
@_copy_docstring_and_deprecators(Axes.eventplot)
|
|
3464
|
+
def eventplot(
|
|
3465
|
+
positions: ArrayLike | Sequence[ArrayLike],
|
|
3466
|
+
orientation: Literal["horizontal", "vertical"] = "horizontal",
|
|
3467
|
+
lineoffsets: float | Sequence[float] = 1,
|
|
3468
|
+
linelengths: float | Sequence[float] = 1,
|
|
3469
|
+
linewidths: float | Sequence[float] | None = None,
|
|
3470
|
+
colors: ColorType | Sequence[ColorType] | None = None,
|
|
3471
|
+
alpha: float | Sequence[float] | None = None,
|
|
3472
|
+
linestyles: LineStyleType | Sequence[LineStyleType] = "solid",
|
|
3473
|
+
*,
|
|
3474
|
+
data: DataParamType = None,
|
|
3475
|
+
**kwargs,
|
|
3476
|
+
) -> EventCollection:
|
|
3477
|
+
return gca().eventplot(
|
|
3478
|
+
positions,
|
|
3479
|
+
orientation=orientation,
|
|
3480
|
+
lineoffsets=lineoffsets,
|
|
3481
|
+
linelengths=linelengths,
|
|
3482
|
+
linewidths=linewidths,
|
|
3483
|
+
colors=colors,
|
|
3484
|
+
alpha=alpha,
|
|
3485
|
+
linestyles=linestyles,
|
|
3486
|
+
**({"data": data} if data is not None else {}),
|
|
3487
|
+
**kwargs,
|
|
3488
|
+
)
|
|
3489
|
+
|
|
3490
|
+
|
|
3491
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
3492
|
+
@_copy_docstring_and_deprecators(Axes.fill)
|
|
3493
|
+
def fill(*args, data: DataParamType = None, **kwargs) -> list[Polygon]:
|
|
3494
|
+
return gca().fill(*args, **({"data": data} if data is not None else {}), **kwargs)
|
|
3495
|
+
|
|
3496
|
+
|
|
3497
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
3498
|
+
@_copy_docstring_and_deprecators(Axes.fill_between)
|
|
3499
|
+
def fill_between(
|
|
3500
|
+
x: ArrayLike,
|
|
3501
|
+
y1: ArrayLike | float,
|
|
3502
|
+
y2: ArrayLike | float = 0,
|
|
3503
|
+
where: ArrayLike | None = None,
|
|
3504
|
+
interpolate: bool = False,
|
|
3505
|
+
step: Literal["pre", "post", "mid"] | None = None,
|
|
3506
|
+
*,
|
|
3507
|
+
data: DataParamType = None,
|
|
3508
|
+
**kwargs,
|
|
3509
|
+
) -> FillBetweenPolyCollection:
|
|
3510
|
+
return gca().fill_between(
|
|
3511
|
+
x,
|
|
3512
|
+
y1,
|
|
3513
|
+
y2=y2,
|
|
3514
|
+
where=where,
|
|
3515
|
+
interpolate=interpolate,
|
|
3516
|
+
step=step,
|
|
3517
|
+
**({"data": data} if data is not None else {}),
|
|
3518
|
+
**kwargs,
|
|
3519
|
+
)
|
|
3520
|
+
|
|
3521
|
+
|
|
3522
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
3523
|
+
@_copy_docstring_and_deprecators(Axes.fill_betweenx)
|
|
3524
|
+
def fill_betweenx(
|
|
3525
|
+
y: ArrayLike,
|
|
3526
|
+
x1: ArrayLike | float,
|
|
3527
|
+
x2: ArrayLike | float = 0,
|
|
3528
|
+
where: ArrayLike | None = None,
|
|
3529
|
+
step: Literal["pre", "post", "mid"] | None = None,
|
|
3530
|
+
interpolate: bool = False,
|
|
3531
|
+
*,
|
|
3532
|
+
data: DataParamType = None,
|
|
3533
|
+
**kwargs,
|
|
3534
|
+
) -> FillBetweenPolyCollection:
|
|
3535
|
+
return gca().fill_betweenx(
|
|
3536
|
+
y,
|
|
3537
|
+
x1,
|
|
3538
|
+
x2=x2,
|
|
3539
|
+
where=where,
|
|
3540
|
+
step=step,
|
|
3541
|
+
interpolate=interpolate,
|
|
3542
|
+
**({"data": data} if data is not None else {}),
|
|
3543
|
+
**kwargs,
|
|
3544
|
+
)
|
|
3545
|
+
|
|
3546
|
+
|
|
3547
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
3548
|
+
@_copy_docstring_and_deprecators(Axes.grid)
|
|
3549
|
+
def grid(
|
|
3550
|
+
visible: bool | None = None,
|
|
3551
|
+
which: Literal["major", "minor", "both"] = "major",
|
|
3552
|
+
axis: Literal["both", "x", "y"] = "both",
|
|
3553
|
+
**kwargs,
|
|
3554
|
+
) -> None:
|
|
3555
|
+
gca().grid(visible=visible, which=which, axis=axis, **kwargs)
|
|
3556
|
+
|
|
3557
|
+
|
|
3558
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
3559
|
+
@_copy_docstring_and_deprecators(Axes.grouped_bar)
|
|
3560
|
+
def grouped_bar(
|
|
3561
|
+
heights: Sequence[ArrayLike] | dict[str, ArrayLike] | np.ndarray | pd.DataFrame,
|
|
3562
|
+
*,
|
|
3563
|
+
positions: ArrayLike | None = None,
|
|
3564
|
+
group_spacing: float | None = 1.5,
|
|
3565
|
+
bar_spacing: float | None = 0,
|
|
3566
|
+
tick_labels: Sequence[str] | None = None,
|
|
3567
|
+
labels: Sequence[str] | None = None,
|
|
3568
|
+
orientation: Literal["vertical", "horizontal"] = "vertical",
|
|
3569
|
+
colors: Iterable[ColorType] | None = None,
|
|
3570
|
+
**kwargs,
|
|
3571
|
+
) -> list[BarContainer]:
|
|
3572
|
+
return gca().grouped_bar(
|
|
3573
|
+
heights,
|
|
3574
|
+
positions=positions,
|
|
3575
|
+
group_spacing=group_spacing,
|
|
3576
|
+
bar_spacing=bar_spacing,
|
|
3577
|
+
tick_labels=tick_labels,
|
|
3578
|
+
labels=labels,
|
|
3579
|
+
orientation=orientation,
|
|
3580
|
+
colors=colors,
|
|
3581
|
+
**kwargs,
|
|
3582
|
+
)
|
|
3583
|
+
|
|
3584
|
+
|
|
3585
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
3586
|
+
@_copy_docstring_and_deprecators(Axes.hexbin)
|
|
3587
|
+
def hexbin(
|
|
3588
|
+
x: ArrayLike,
|
|
3589
|
+
y: ArrayLike,
|
|
3590
|
+
C: ArrayLike | None = None,
|
|
3591
|
+
gridsize: int | tuple[int, int] = 100,
|
|
3592
|
+
bins: Literal["log"] | int | Sequence[float] | None = None,
|
|
3593
|
+
xscale: Literal["linear", "log"] = "linear",
|
|
3594
|
+
yscale: Literal["linear", "log"] = "linear",
|
|
3595
|
+
extent: tuple[float, float, float, float] | None = None,
|
|
3596
|
+
cmap: str | Colormap | None = None,
|
|
3597
|
+
norm: str | Normalize | None = None,
|
|
3598
|
+
vmin: float | None = None,
|
|
3599
|
+
vmax: float | None = None,
|
|
3600
|
+
alpha: float | None = None,
|
|
3601
|
+
linewidths: float | None = None,
|
|
3602
|
+
edgecolors: Literal["face", "none"] | ColorType = "face",
|
|
3603
|
+
reduce_C_function: Callable[[np.ndarray | list[float]], float] = np.mean,
|
|
3604
|
+
mincnt: int | None = None,
|
|
3605
|
+
marginals: bool = False,
|
|
3606
|
+
colorizer: Colorizer | None = None,
|
|
3607
|
+
*,
|
|
3608
|
+
data: DataParamType = None,
|
|
3609
|
+
**kwargs,
|
|
3610
|
+
) -> PolyCollection:
|
|
3611
|
+
__ret = gca().hexbin(
|
|
3612
|
+
x,
|
|
3613
|
+
y,
|
|
3614
|
+
C=C,
|
|
3615
|
+
gridsize=gridsize,
|
|
3616
|
+
bins=bins,
|
|
3617
|
+
xscale=xscale,
|
|
3618
|
+
yscale=yscale,
|
|
3619
|
+
extent=extent,
|
|
3620
|
+
cmap=cmap,
|
|
3621
|
+
norm=norm,
|
|
3622
|
+
vmin=vmin,
|
|
3623
|
+
vmax=vmax,
|
|
3624
|
+
alpha=alpha,
|
|
3625
|
+
linewidths=linewidths,
|
|
3626
|
+
edgecolors=edgecolors,
|
|
3627
|
+
reduce_C_function=reduce_C_function,
|
|
3628
|
+
mincnt=mincnt,
|
|
3629
|
+
marginals=marginals,
|
|
3630
|
+
colorizer=colorizer,
|
|
3631
|
+
**({"data": data} if data is not None else {}),
|
|
3632
|
+
**kwargs,
|
|
3633
|
+
)
|
|
3634
|
+
sci(__ret)
|
|
3635
|
+
return __ret
|
|
3636
|
+
|
|
3637
|
+
|
|
3638
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
3639
|
+
@_copy_docstring_and_deprecators(Axes.hist)
|
|
3640
|
+
def hist(
|
|
3641
|
+
x: ArrayLike | Sequence[ArrayLike],
|
|
3642
|
+
bins: int | Sequence[float] | str | None = None,
|
|
3643
|
+
range: tuple[float, float] | None = None,
|
|
3644
|
+
density: bool = False,
|
|
3645
|
+
weights: ArrayLike | None = None,
|
|
3646
|
+
cumulative: bool | float = False,
|
|
3647
|
+
bottom: ArrayLike | float | None = None,
|
|
3648
|
+
histtype: Literal["bar", "barstacked", "step", "stepfilled"] = "bar",
|
|
3649
|
+
align: Literal["left", "mid", "right"] = "mid",
|
|
3650
|
+
orientation: Literal["vertical", "horizontal"] = "vertical",
|
|
3651
|
+
rwidth: float | None = None,
|
|
3652
|
+
log: bool = False,
|
|
3653
|
+
color: ColorType | Sequence[ColorType] | None = None,
|
|
3654
|
+
label: str | Sequence[str] | None = None,
|
|
3655
|
+
stacked: bool = False,
|
|
3656
|
+
*,
|
|
3657
|
+
data: DataParamType = None,
|
|
3658
|
+
**kwargs,
|
|
3659
|
+
) -> tuple[
|
|
3660
|
+
np.ndarray | list[np.ndarray],
|
|
3661
|
+
np.ndarray,
|
|
3662
|
+
BarContainer | Polygon | list[BarContainer | Polygon],
|
|
3663
|
+
]:
|
|
3664
|
+
return gca().hist(
|
|
3665
|
+
x,
|
|
3666
|
+
bins=bins,
|
|
3667
|
+
range=range,
|
|
3668
|
+
density=density,
|
|
3669
|
+
weights=weights,
|
|
3670
|
+
cumulative=cumulative,
|
|
3671
|
+
bottom=bottom,
|
|
3672
|
+
histtype=histtype,
|
|
3673
|
+
align=align,
|
|
3674
|
+
orientation=orientation,
|
|
3675
|
+
rwidth=rwidth,
|
|
3676
|
+
log=log,
|
|
3677
|
+
color=color,
|
|
3678
|
+
label=label,
|
|
3679
|
+
stacked=stacked,
|
|
3680
|
+
**({"data": data} if data is not None else {}),
|
|
3681
|
+
**kwargs,
|
|
3682
|
+
)
|
|
3683
|
+
|
|
3684
|
+
|
|
3685
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
3686
|
+
@_copy_docstring_and_deprecators(Axes.stairs)
|
|
3687
|
+
def stairs(
|
|
3688
|
+
values: ArrayLike,
|
|
3689
|
+
edges: ArrayLike | None = None,
|
|
3690
|
+
*,
|
|
3691
|
+
orientation: Literal["vertical", "horizontal"] = "vertical",
|
|
3692
|
+
baseline: float | ArrayLike | None = 0,
|
|
3693
|
+
fill: bool = False,
|
|
3694
|
+
data: DataParamType = None,
|
|
3695
|
+
**kwargs,
|
|
3696
|
+
) -> StepPatch:
|
|
3697
|
+
return gca().stairs(
|
|
3698
|
+
values,
|
|
3699
|
+
edges=edges,
|
|
3700
|
+
orientation=orientation,
|
|
3701
|
+
baseline=baseline,
|
|
3702
|
+
fill=fill,
|
|
3703
|
+
**({"data": data} if data is not None else {}),
|
|
3704
|
+
**kwargs,
|
|
3705
|
+
)
|
|
3706
|
+
|
|
3707
|
+
|
|
3708
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
3709
|
+
@_copy_docstring_and_deprecators(Axes.hist2d)
|
|
3710
|
+
def hist2d(
|
|
3711
|
+
x: ArrayLike,
|
|
3712
|
+
y: ArrayLike,
|
|
3713
|
+
bins: None | int | tuple[int, int] | ArrayLike | tuple[ArrayLike, ArrayLike] = 10,
|
|
3714
|
+
range: ArrayLike | None = None,
|
|
3715
|
+
density: bool = False,
|
|
3716
|
+
weights: ArrayLike | None = None,
|
|
3717
|
+
cmin: float | None = None,
|
|
3718
|
+
cmax: float | None = None,
|
|
3719
|
+
*,
|
|
3720
|
+
data: DataParamType = None,
|
|
3721
|
+
**kwargs,
|
|
3722
|
+
) -> tuple[np.ndarray, np.ndarray, np.ndarray, QuadMesh]:
|
|
3723
|
+
__ret = gca().hist2d(
|
|
3724
|
+
x,
|
|
3725
|
+
y,
|
|
3726
|
+
bins=bins,
|
|
3727
|
+
range=range,
|
|
3728
|
+
density=density,
|
|
3729
|
+
weights=weights,
|
|
3730
|
+
cmin=cmin,
|
|
3731
|
+
cmax=cmax,
|
|
3732
|
+
**({"data": data} if data is not None else {}),
|
|
3733
|
+
**kwargs,
|
|
3734
|
+
)
|
|
3735
|
+
sci(__ret[-1])
|
|
3736
|
+
return __ret
|
|
3737
|
+
|
|
3738
|
+
|
|
3739
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
3740
|
+
@_copy_docstring_and_deprecators(Axes.hlines)
|
|
3741
|
+
def hlines(
|
|
3742
|
+
y: float | ArrayLike,
|
|
3743
|
+
xmin: float | ArrayLike,
|
|
3744
|
+
xmax: float | ArrayLike,
|
|
3745
|
+
colors: ColorType | Sequence[ColorType] | None = None,
|
|
3746
|
+
linestyles: LineStyleType = "solid",
|
|
3747
|
+
label: str = "",
|
|
3748
|
+
*,
|
|
3749
|
+
data: DataParamType = None,
|
|
3750
|
+
**kwargs,
|
|
3751
|
+
) -> LineCollection:
|
|
3752
|
+
return gca().hlines(
|
|
3753
|
+
y,
|
|
3754
|
+
xmin,
|
|
3755
|
+
xmax,
|
|
3756
|
+
colors=colors,
|
|
3757
|
+
linestyles=linestyles,
|
|
3758
|
+
label=label,
|
|
3759
|
+
**({"data": data} if data is not None else {}),
|
|
3760
|
+
**kwargs,
|
|
3761
|
+
)
|
|
3762
|
+
|
|
3763
|
+
|
|
3764
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
3765
|
+
@_copy_docstring_and_deprecators(Axes.imshow)
|
|
3766
|
+
def imshow(
|
|
3767
|
+
X: ArrayLike | PIL.Image.Image,
|
|
3768
|
+
cmap: str | Colormap | None = None,
|
|
3769
|
+
norm: str | Normalize | None = None,
|
|
3770
|
+
*,
|
|
3771
|
+
aspect: Literal["equal", "auto"] | float | None = None,
|
|
3772
|
+
interpolation: str | None = None,
|
|
3773
|
+
alpha: float | ArrayLike | None = None,
|
|
3774
|
+
vmin: float | None = None,
|
|
3775
|
+
vmax: float | None = None,
|
|
3776
|
+
colorizer: Colorizer | None = None,
|
|
3777
|
+
origin: Literal["upper", "lower"] | None = None,
|
|
3778
|
+
extent: tuple[float, float, float, float] | None = None,
|
|
3779
|
+
interpolation_stage: Literal["data", "rgba", "auto"] | None = None,
|
|
3780
|
+
filternorm: bool = True,
|
|
3781
|
+
filterrad: float = 4.0,
|
|
3782
|
+
resample: bool | None = None,
|
|
3783
|
+
url: str | None = None,
|
|
3784
|
+
data: DataParamType = None,
|
|
3785
|
+
**kwargs,
|
|
3786
|
+
) -> AxesImage:
|
|
3787
|
+
__ret = gca().imshow(
|
|
3788
|
+
X,
|
|
3789
|
+
cmap=cmap,
|
|
3790
|
+
norm=norm,
|
|
3791
|
+
aspect=aspect,
|
|
3792
|
+
interpolation=interpolation,
|
|
3793
|
+
alpha=alpha,
|
|
3794
|
+
vmin=vmin,
|
|
3795
|
+
vmax=vmax,
|
|
3796
|
+
colorizer=colorizer,
|
|
3797
|
+
origin=origin,
|
|
3798
|
+
extent=extent,
|
|
3799
|
+
interpolation_stage=interpolation_stage,
|
|
3800
|
+
filternorm=filternorm,
|
|
3801
|
+
filterrad=filterrad,
|
|
3802
|
+
resample=resample,
|
|
3803
|
+
url=url,
|
|
3804
|
+
**({"data": data} if data is not None else {}),
|
|
3805
|
+
**kwargs,
|
|
3806
|
+
)
|
|
3807
|
+
sci(__ret)
|
|
3808
|
+
return __ret
|
|
3809
|
+
|
|
3810
|
+
|
|
3811
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
3812
|
+
@_copy_docstring_and_deprecators(Axes.legend)
|
|
3813
|
+
def legend(*args, **kwargs) -> Legend:
|
|
3814
|
+
return gca().legend(*args, **kwargs)
|
|
3815
|
+
|
|
3816
|
+
|
|
3817
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
3818
|
+
@_copy_docstring_and_deprecators(Axes.locator_params)
|
|
3819
|
+
def locator_params(
|
|
3820
|
+
axis: Literal["both", "x", "y"] = "both", tight: bool | None = None, **kwargs
|
|
3821
|
+
) -> None:
|
|
3822
|
+
gca().locator_params(axis=axis, tight=tight, **kwargs)
|
|
3823
|
+
|
|
3824
|
+
|
|
3825
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
3826
|
+
@_copy_docstring_and_deprecators(Axes.loglog)
|
|
3827
|
+
def loglog(*args, **kwargs) -> list[Line2D]:
|
|
3828
|
+
return gca().loglog(*args, **kwargs)
|
|
3829
|
+
|
|
3830
|
+
|
|
3831
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
3832
|
+
@_copy_docstring_and_deprecators(Axes.magnitude_spectrum)
|
|
3833
|
+
def magnitude_spectrum(
|
|
3834
|
+
x: ArrayLike,
|
|
3835
|
+
Fs: float | None = None,
|
|
3836
|
+
Fc: int | None = None,
|
|
3837
|
+
window: Callable[[ArrayLike], ArrayLike] | ArrayLike | None = None,
|
|
3838
|
+
pad_to: int | None = None,
|
|
3839
|
+
sides: Literal["default", "onesided", "twosided"] | None = None,
|
|
3840
|
+
scale: Literal["default", "linear", "dB"] | None = None,
|
|
3841
|
+
*,
|
|
3842
|
+
data: DataParamType = None,
|
|
3843
|
+
**kwargs,
|
|
3844
|
+
) -> tuple[np.ndarray, np.ndarray, Line2D]:
|
|
3845
|
+
return gca().magnitude_spectrum(
|
|
3846
|
+
x,
|
|
3847
|
+
Fs=Fs,
|
|
3848
|
+
Fc=Fc,
|
|
3849
|
+
window=window,
|
|
3850
|
+
pad_to=pad_to,
|
|
3851
|
+
sides=sides,
|
|
3852
|
+
scale=scale,
|
|
3853
|
+
**({"data": data} if data is not None else {}),
|
|
3854
|
+
**kwargs,
|
|
3855
|
+
)
|
|
3856
|
+
|
|
3857
|
+
|
|
3858
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
3859
|
+
@_copy_docstring_and_deprecators(Axes.margins)
|
|
3860
|
+
def margins(
|
|
3861
|
+
*margins: float,
|
|
3862
|
+
x: float | None = None,
|
|
3863
|
+
y: float | None = None,
|
|
3864
|
+
tight: bool | None = True,
|
|
3865
|
+
) -> tuple[float, float] | None:
|
|
3866
|
+
return gca().margins(*margins, x=x, y=y, tight=tight)
|
|
3867
|
+
|
|
3868
|
+
|
|
3869
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
3870
|
+
@_copy_docstring_and_deprecators(Axes.minorticks_off)
|
|
3871
|
+
def minorticks_off() -> None:
|
|
3872
|
+
gca().minorticks_off()
|
|
3873
|
+
|
|
3874
|
+
|
|
3875
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
3876
|
+
@_copy_docstring_and_deprecators(Axes.minorticks_on)
|
|
3877
|
+
def minorticks_on() -> None:
|
|
3878
|
+
gca().minorticks_on()
|
|
3879
|
+
|
|
3880
|
+
|
|
3881
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
3882
|
+
@_copy_docstring_and_deprecators(Axes.pcolor)
|
|
3883
|
+
def pcolor(
|
|
3884
|
+
*args: ArrayLike,
|
|
3885
|
+
shading: Literal["flat", "nearest", "auto"] | None = None,
|
|
3886
|
+
alpha: float | None = None,
|
|
3887
|
+
norm: str | Normalize | None = None,
|
|
3888
|
+
cmap: str | Colormap | None = None,
|
|
3889
|
+
vmin: float | None = None,
|
|
3890
|
+
vmax: float | None = None,
|
|
3891
|
+
colorizer: Colorizer | None = None,
|
|
3892
|
+
data: DataParamType = None,
|
|
3893
|
+
**kwargs,
|
|
3894
|
+
) -> Collection:
|
|
3895
|
+
__ret = gca().pcolor(
|
|
3896
|
+
*args,
|
|
3897
|
+
shading=shading,
|
|
3898
|
+
alpha=alpha,
|
|
3899
|
+
norm=norm,
|
|
3900
|
+
cmap=cmap,
|
|
3901
|
+
vmin=vmin,
|
|
3902
|
+
vmax=vmax,
|
|
3903
|
+
colorizer=colorizer,
|
|
3904
|
+
**({"data": data} if data is not None else {}),
|
|
3905
|
+
**kwargs,
|
|
3906
|
+
)
|
|
3907
|
+
sci(__ret)
|
|
3908
|
+
return __ret
|
|
3909
|
+
|
|
3910
|
+
|
|
3911
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
3912
|
+
@_copy_docstring_and_deprecators(Axes.pcolormesh)
|
|
3913
|
+
def pcolormesh(
|
|
3914
|
+
*args: ArrayLike,
|
|
3915
|
+
alpha: float | None = None,
|
|
3916
|
+
norm: str | Normalize | None = None,
|
|
3917
|
+
cmap: str | Colormap | None = None,
|
|
3918
|
+
vmin: float | None = None,
|
|
3919
|
+
vmax: float | None = None,
|
|
3920
|
+
colorizer: Colorizer | None = None,
|
|
3921
|
+
shading: Literal["flat", "nearest", "gouraud", "auto"] | None = None,
|
|
3922
|
+
antialiased: bool = False,
|
|
3923
|
+
data: DataParamType = None,
|
|
3924
|
+
**kwargs,
|
|
3925
|
+
) -> QuadMesh:
|
|
3926
|
+
__ret = gca().pcolormesh(
|
|
3927
|
+
*args,
|
|
3928
|
+
alpha=alpha,
|
|
3929
|
+
norm=norm,
|
|
3930
|
+
cmap=cmap,
|
|
3931
|
+
vmin=vmin,
|
|
3932
|
+
vmax=vmax,
|
|
3933
|
+
colorizer=colorizer,
|
|
3934
|
+
shading=shading,
|
|
3935
|
+
antialiased=antialiased,
|
|
3936
|
+
**({"data": data} if data is not None else {}),
|
|
3937
|
+
**kwargs,
|
|
3938
|
+
)
|
|
3939
|
+
sci(__ret)
|
|
3940
|
+
return __ret
|
|
3941
|
+
|
|
3942
|
+
|
|
3943
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
3944
|
+
@_copy_docstring_and_deprecators(Axes.phase_spectrum)
|
|
3945
|
+
def phase_spectrum(
|
|
3946
|
+
x: ArrayLike,
|
|
3947
|
+
Fs: float | None = None,
|
|
3948
|
+
Fc: int | None = None,
|
|
3949
|
+
window: Callable[[ArrayLike], ArrayLike] | ArrayLike | None = None,
|
|
3950
|
+
pad_to: int | None = None,
|
|
3951
|
+
sides: Literal["default", "onesided", "twosided"] | None = None,
|
|
3952
|
+
*,
|
|
3953
|
+
data: DataParamType = None,
|
|
3954
|
+
**kwargs,
|
|
3955
|
+
) -> tuple[np.ndarray, np.ndarray, Line2D]:
|
|
3956
|
+
return gca().phase_spectrum(
|
|
3957
|
+
x,
|
|
3958
|
+
Fs=Fs,
|
|
3959
|
+
Fc=Fc,
|
|
3960
|
+
window=window,
|
|
3961
|
+
pad_to=pad_to,
|
|
3962
|
+
sides=sides,
|
|
3963
|
+
**({"data": data} if data is not None else {}),
|
|
3964
|
+
**kwargs,
|
|
3965
|
+
)
|
|
3966
|
+
|
|
3967
|
+
|
|
3968
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
3969
|
+
@_copy_docstring_and_deprecators(Axes.pie)
|
|
3970
|
+
def pie(
|
|
3971
|
+
x: ArrayLike,
|
|
3972
|
+
explode: ArrayLike | None = None,
|
|
3973
|
+
labels: Sequence[str] | None = None,
|
|
3974
|
+
colors: ColorType | Sequence[ColorType] | None = None,
|
|
3975
|
+
autopct: str | Callable[[float], str] | None = None,
|
|
3976
|
+
pctdistance: float = 0.6,
|
|
3977
|
+
shadow: bool = False,
|
|
3978
|
+
labeldistance: float | None = 1.1,
|
|
3979
|
+
startangle: float = 0,
|
|
3980
|
+
radius: float = 1,
|
|
3981
|
+
counterclock: bool = True,
|
|
3982
|
+
wedgeprops: dict[str, Any] | None = None,
|
|
3983
|
+
textprops: dict[str, Any] | None = None,
|
|
3984
|
+
center: tuple[float, float] = (0, 0),
|
|
3985
|
+
frame: bool = False,
|
|
3986
|
+
rotatelabels: bool = False,
|
|
3987
|
+
*,
|
|
3988
|
+
normalize: bool = True,
|
|
3989
|
+
hatch: str | Sequence[str] | None = None,
|
|
3990
|
+
data: DataParamType = None,
|
|
3991
|
+
) -> PieContainer:
|
|
3992
|
+
return gca().pie(
|
|
3993
|
+
x,
|
|
3994
|
+
explode=explode,
|
|
3995
|
+
labels=labels,
|
|
3996
|
+
colors=colors,
|
|
3997
|
+
autopct=autopct,
|
|
3998
|
+
pctdistance=pctdistance,
|
|
3999
|
+
shadow=shadow,
|
|
4000
|
+
labeldistance=labeldistance,
|
|
4001
|
+
startangle=startangle,
|
|
4002
|
+
radius=radius,
|
|
4003
|
+
counterclock=counterclock,
|
|
4004
|
+
wedgeprops=wedgeprops,
|
|
4005
|
+
textprops=textprops,
|
|
4006
|
+
center=center,
|
|
4007
|
+
frame=frame,
|
|
4008
|
+
rotatelabels=rotatelabels,
|
|
4009
|
+
normalize=normalize,
|
|
4010
|
+
hatch=hatch,
|
|
4011
|
+
**({"data": data} if data is not None else {}),
|
|
4012
|
+
)
|
|
4013
|
+
|
|
4014
|
+
|
|
4015
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
4016
|
+
@_copy_docstring_and_deprecators(Axes.pie_label)
|
|
4017
|
+
def pie_label(
|
|
4018
|
+
container: PieContainer,
|
|
4019
|
+
/,
|
|
4020
|
+
labels: str | Sequence[str],
|
|
4021
|
+
*,
|
|
4022
|
+
distance: float = 0.6,
|
|
4023
|
+
textprops: dict | None = None,
|
|
4024
|
+
rotate: bool = False,
|
|
4025
|
+
alignment: str = "auto",
|
|
4026
|
+
) -> list[Text]:
|
|
4027
|
+
return gca().pie_label(
|
|
4028
|
+
container,
|
|
4029
|
+
labels,
|
|
4030
|
+
distance=distance,
|
|
4031
|
+
textprops=textprops,
|
|
4032
|
+
rotate=rotate,
|
|
4033
|
+
alignment=alignment,
|
|
4034
|
+
)
|
|
4035
|
+
|
|
4036
|
+
|
|
4037
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
4038
|
+
@_copy_docstring_and_deprecators(Axes.plot)
|
|
4039
|
+
def plot(
|
|
4040
|
+
*args: float | ArrayLike | str,
|
|
4041
|
+
scalex: bool = True,
|
|
4042
|
+
scaley: bool = True,
|
|
4043
|
+
data: DataParamType = None,
|
|
4044
|
+
**kwargs,
|
|
4045
|
+
) -> list[Line2D]:
|
|
4046
|
+
return gca().plot(
|
|
4047
|
+
*args,
|
|
4048
|
+
scalex=scalex,
|
|
4049
|
+
scaley=scaley,
|
|
4050
|
+
**({"data": data} if data is not None else {}),
|
|
4051
|
+
**kwargs,
|
|
4052
|
+
)
|
|
4053
|
+
|
|
4054
|
+
|
|
4055
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
4056
|
+
@_copy_docstring_and_deprecators(Axes.psd)
|
|
4057
|
+
def psd(
|
|
4058
|
+
x: ArrayLike,
|
|
4059
|
+
NFFT: int | None = None,
|
|
4060
|
+
Fs: float | None = None,
|
|
4061
|
+
Fc: int | None = None,
|
|
4062
|
+
detrend: (
|
|
4063
|
+
Literal["none", "mean", "linear"] | Callable[[ArrayLike], ArrayLike] | None
|
|
4064
|
+
) = None,
|
|
4065
|
+
window: Callable[[ArrayLike], ArrayLike] | ArrayLike | None = None,
|
|
4066
|
+
noverlap: int | None = None,
|
|
4067
|
+
pad_to: int | None = None,
|
|
4068
|
+
sides: Literal["default", "onesided", "twosided"] | None = None,
|
|
4069
|
+
scale_by_freq: bool | None = None,
|
|
4070
|
+
return_line: bool | None = None,
|
|
4071
|
+
*,
|
|
4072
|
+
data: DataParamType = None,
|
|
4073
|
+
**kwargs,
|
|
4074
|
+
) -> tuple[np.ndarray, np.ndarray] | tuple[np.ndarray, np.ndarray, Line2D]:
|
|
4075
|
+
return gca().psd(
|
|
4076
|
+
x,
|
|
4077
|
+
NFFT=NFFT,
|
|
4078
|
+
Fs=Fs,
|
|
4079
|
+
Fc=Fc,
|
|
4080
|
+
detrend=detrend,
|
|
4081
|
+
window=window,
|
|
4082
|
+
noverlap=noverlap,
|
|
4083
|
+
pad_to=pad_to,
|
|
4084
|
+
sides=sides,
|
|
4085
|
+
scale_by_freq=scale_by_freq,
|
|
4086
|
+
return_line=return_line,
|
|
4087
|
+
**({"data": data} if data is not None else {}),
|
|
4088
|
+
**kwargs,
|
|
4089
|
+
)
|
|
4090
|
+
|
|
4091
|
+
|
|
4092
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
4093
|
+
@_copy_docstring_and_deprecators(Axes.quiver)
|
|
4094
|
+
def quiver(*args, data: DataParamType = None, **kwargs) -> Quiver:
|
|
4095
|
+
__ret = gca().quiver(
|
|
4096
|
+
*args, **({"data": data} if data is not None else {}), **kwargs
|
|
4097
|
+
)
|
|
4098
|
+
sci(__ret)
|
|
4099
|
+
return __ret
|
|
4100
|
+
|
|
4101
|
+
|
|
4102
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
4103
|
+
@_copy_docstring_and_deprecators(Axes.quiverkey)
|
|
4104
|
+
def quiverkey(
|
|
4105
|
+
Q: Quiver, X: float, Y: float, U: float, label: str, **kwargs
|
|
4106
|
+
) -> QuiverKey:
|
|
4107
|
+
return gca().quiverkey(Q, X, Y, U, label, **kwargs)
|
|
4108
|
+
|
|
4109
|
+
|
|
4110
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
4111
|
+
@_copy_docstring_and_deprecators(Axes.scatter)
|
|
4112
|
+
def scatter(
|
|
4113
|
+
x: float | ArrayLike,
|
|
4114
|
+
y: float | ArrayLike,
|
|
4115
|
+
s: float | ArrayLike | None = None,
|
|
4116
|
+
c: ArrayLike | Sequence[ColorType] | ColorType | None = None,
|
|
4117
|
+
marker: MarkerType | None = None,
|
|
4118
|
+
cmap: str | Colormap | None = None,
|
|
4119
|
+
norm: str | Normalize | None = None,
|
|
4120
|
+
vmin: float | None = None,
|
|
4121
|
+
vmax: float | None = None,
|
|
4122
|
+
alpha: float | None = None,
|
|
4123
|
+
linewidths: float | Sequence[float] | None = None,
|
|
4124
|
+
*,
|
|
4125
|
+
edgecolors: Literal["face", "none"] | ColorType | Sequence[ColorType] | None = None,
|
|
4126
|
+
colorizer: Colorizer | None = None,
|
|
4127
|
+
plotnonfinite: bool = False,
|
|
4128
|
+
data: DataParamType = None,
|
|
4129
|
+
**kwargs,
|
|
4130
|
+
) -> PathCollection:
|
|
4131
|
+
__ret = gca().scatter(
|
|
4132
|
+
x,
|
|
4133
|
+
y,
|
|
4134
|
+
s=s,
|
|
4135
|
+
c=c,
|
|
4136
|
+
marker=marker,
|
|
4137
|
+
cmap=cmap,
|
|
4138
|
+
norm=norm,
|
|
4139
|
+
vmin=vmin,
|
|
4140
|
+
vmax=vmax,
|
|
4141
|
+
alpha=alpha,
|
|
4142
|
+
linewidths=linewidths,
|
|
4143
|
+
edgecolors=edgecolors,
|
|
4144
|
+
colorizer=colorizer,
|
|
4145
|
+
plotnonfinite=plotnonfinite,
|
|
4146
|
+
**({"data": data} if data is not None else {}),
|
|
4147
|
+
**kwargs,
|
|
4148
|
+
)
|
|
4149
|
+
sci(__ret)
|
|
4150
|
+
return __ret
|
|
4151
|
+
|
|
4152
|
+
|
|
4153
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
4154
|
+
@_copy_docstring_and_deprecators(Axes.semilogx)
|
|
4155
|
+
def semilogx(*args, **kwargs) -> list[Line2D]:
|
|
4156
|
+
return gca().semilogx(*args, **kwargs)
|
|
4157
|
+
|
|
4158
|
+
|
|
4159
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
4160
|
+
@_copy_docstring_and_deprecators(Axes.semilogy)
|
|
4161
|
+
def semilogy(*args, **kwargs) -> list[Line2D]:
|
|
4162
|
+
return gca().semilogy(*args, **kwargs)
|
|
4163
|
+
|
|
4164
|
+
|
|
4165
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
4166
|
+
@_copy_docstring_and_deprecators(Axes.specgram)
|
|
4167
|
+
def specgram(
|
|
4168
|
+
x: ArrayLike,
|
|
4169
|
+
NFFT: int | None = None,
|
|
4170
|
+
Fs: float | None = None,
|
|
4171
|
+
Fc: int | None = None,
|
|
4172
|
+
detrend: (
|
|
4173
|
+
Literal["none", "mean", "linear"] | Callable[[ArrayLike], ArrayLike] | None
|
|
4174
|
+
) = None,
|
|
4175
|
+
window: Callable[[ArrayLike], ArrayLike] | ArrayLike | None = None,
|
|
4176
|
+
noverlap: int | None = None,
|
|
4177
|
+
cmap: str | Colormap | None = None,
|
|
4178
|
+
xextent: tuple[float, float] | None = None,
|
|
4179
|
+
pad_to: int | None = None,
|
|
4180
|
+
sides: Literal["default", "onesided", "twosided"] | None = None,
|
|
4181
|
+
scale_by_freq: bool | None = None,
|
|
4182
|
+
mode: Literal["default", "psd", "magnitude", "angle", "phase"] | None = None,
|
|
4183
|
+
scale: Literal["default", "linear", "dB"] | None = None,
|
|
4184
|
+
vmin: float | None = None,
|
|
4185
|
+
vmax: float | None = None,
|
|
4186
|
+
*,
|
|
4187
|
+
data: DataParamType = None,
|
|
4188
|
+
**kwargs,
|
|
4189
|
+
) -> tuple[np.ndarray, np.ndarray, np.ndarray, AxesImage]:
|
|
4190
|
+
__ret = gca().specgram(
|
|
4191
|
+
x,
|
|
4192
|
+
NFFT=NFFT,
|
|
4193
|
+
Fs=Fs,
|
|
4194
|
+
Fc=Fc,
|
|
4195
|
+
detrend=detrend,
|
|
4196
|
+
window=window,
|
|
4197
|
+
noverlap=noverlap,
|
|
4198
|
+
cmap=cmap,
|
|
4199
|
+
xextent=xextent,
|
|
4200
|
+
pad_to=pad_to,
|
|
4201
|
+
sides=sides,
|
|
4202
|
+
scale_by_freq=scale_by_freq,
|
|
4203
|
+
mode=mode,
|
|
4204
|
+
scale=scale,
|
|
4205
|
+
vmin=vmin,
|
|
4206
|
+
vmax=vmax,
|
|
4207
|
+
**({"data": data} if data is not None else {}),
|
|
4208
|
+
**kwargs,
|
|
4209
|
+
)
|
|
4210
|
+
sci(__ret[-1])
|
|
4211
|
+
return __ret
|
|
4212
|
+
|
|
4213
|
+
|
|
4214
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
4215
|
+
@_copy_docstring_and_deprecators(Axes.spy)
|
|
4216
|
+
def spy(
|
|
4217
|
+
Z: ArrayLike,
|
|
4218
|
+
precision: float | Literal["present"] = 0,
|
|
4219
|
+
marker: str | None = None,
|
|
4220
|
+
markersize: float | None = None,
|
|
4221
|
+
aspect: Literal["equal", "auto"] | float | None = "equal",
|
|
4222
|
+
origin: Literal["upper", "lower"] = "upper",
|
|
4223
|
+
**kwargs,
|
|
4224
|
+
) -> AxesImage:
|
|
4225
|
+
__ret = gca().spy(
|
|
4226
|
+
Z,
|
|
4227
|
+
precision=precision,
|
|
4228
|
+
marker=marker,
|
|
4229
|
+
markersize=markersize,
|
|
4230
|
+
aspect=aspect,
|
|
4231
|
+
origin=origin,
|
|
4232
|
+
**kwargs,
|
|
4233
|
+
)
|
|
4234
|
+
if isinstance(__ret, _ColorizerInterface):
|
|
4235
|
+
sci(__ret)
|
|
4236
|
+
return __ret
|
|
4237
|
+
|
|
4238
|
+
|
|
4239
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
4240
|
+
@_copy_docstring_and_deprecators(Axes.stackplot)
|
|
4241
|
+
def stackplot(x, *args, labels=(), colors=None, baseline="zero", data=None, **kwargs):
|
|
4242
|
+
return gca().stackplot(
|
|
4243
|
+
x,
|
|
4244
|
+
*args,
|
|
4245
|
+
labels=labels,
|
|
4246
|
+
colors=colors,
|
|
4247
|
+
baseline=baseline,
|
|
4248
|
+
**({"data": data} if data is not None else {}),
|
|
4249
|
+
**kwargs,
|
|
4250
|
+
)
|
|
4251
|
+
|
|
4252
|
+
|
|
4253
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
4254
|
+
@_copy_docstring_and_deprecators(Axes.stem)
|
|
4255
|
+
def stem(
|
|
4256
|
+
*args: ArrayLike | str,
|
|
4257
|
+
linefmt: str | None = None,
|
|
4258
|
+
markerfmt: str | None = None,
|
|
4259
|
+
basefmt: str | None = None,
|
|
4260
|
+
bottom: float = 0,
|
|
4261
|
+
label: str | None = None,
|
|
4262
|
+
orientation: Literal["vertical", "horizontal"] = "vertical",
|
|
4263
|
+
data: DataParamType = None,
|
|
4264
|
+
) -> StemContainer:
|
|
4265
|
+
return gca().stem(
|
|
4266
|
+
*args,
|
|
4267
|
+
linefmt=linefmt,
|
|
4268
|
+
markerfmt=markerfmt,
|
|
4269
|
+
basefmt=basefmt,
|
|
4270
|
+
bottom=bottom,
|
|
4271
|
+
label=label,
|
|
4272
|
+
orientation=orientation,
|
|
4273
|
+
**({"data": data} if data is not None else {}),
|
|
4274
|
+
)
|
|
4275
|
+
|
|
4276
|
+
|
|
4277
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
4278
|
+
@_copy_docstring_and_deprecators(Axes.step)
|
|
4279
|
+
def step(
|
|
4280
|
+
x: ArrayLike,
|
|
4281
|
+
y: ArrayLike,
|
|
4282
|
+
*args,
|
|
4283
|
+
where: Literal["pre", "post", "mid"] = "pre",
|
|
4284
|
+
data: DataParamType = None,
|
|
4285
|
+
**kwargs,
|
|
4286
|
+
) -> list[Line2D]:
|
|
4287
|
+
return gca().step(
|
|
4288
|
+
x,
|
|
4289
|
+
y,
|
|
4290
|
+
*args,
|
|
4291
|
+
where=where,
|
|
4292
|
+
**({"data": data} if data is not None else {}),
|
|
4293
|
+
**kwargs,
|
|
4294
|
+
)
|
|
4295
|
+
|
|
4296
|
+
|
|
4297
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
4298
|
+
@_copy_docstring_and_deprecators(Axes.streamplot)
|
|
4299
|
+
def streamplot(
|
|
4300
|
+
x,
|
|
4301
|
+
y,
|
|
4302
|
+
u,
|
|
4303
|
+
v,
|
|
4304
|
+
density=1,
|
|
4305
|
+
linewidth=None,
|
|
4306
|
+
color=None,
|
|
4307
|
+
cmap=None,
|
|
4308
|
+
norm=None,
|
|
4309
|
+
arrowsize=1,
|
|
4310
|
+
arrowstyle="-|>",
|
|
4311
|
+
minlength=0.1,
|
|
4312
|
+
transform=None,
|
|
4313
|
+
zorder=None,
|
|
4314
|
+
start_points=None,
|
|
4315
|
+
maxlength=4.0,
|
|
4316
|
+
integration_direction="both",
|
|
4317
|
+
broken_streamlines=True,
|
|
4318
|
+
*,
|
|
4319
|
+
integration_max_step_scale=1.0,
|
|
4320
|
+
integration_max_error_scale=1.0,
|
|
4321
|
+
num_arrows=1,
|
|
4322
|
+
data=None,
|
|
4323
|
+
):
|
|
4324
|
+
__ret = gca().streamplot(
|
|
4325
|
+
x,
|
|
4326
|
+
y,
|
|
4327
|
+
u,
|
|
4328
|
+
v,
|
|
4329
|
+
density=density,
|
|
4330
|
+
linewidth=linewidth,
|
|
4331
|
+
color=color,
|
|
4332
|
+
cmap=cmap,
|
|
4333
|
+
norm=norm,
|
|
4334
|
+
arrowsize=arrowsize,
|
|
4335
|
+
arrowstyle=arrowstyle,
|
|
4336
|
+
minlength=minlength,
|
|
4337
|
+
transform=transform,
|
|
4338
|
+
zorder=zorder,
|
|
4339
|
+
start_points=start_points,
|
|
4340
|
+
maxlength=maxlength,
|
|
4341
|
+
integration_direction=integration_direction,
|
|
4342
|
+
broken_streamlines=broken_streamlines,
|
|
4343
|
+
integration_max_step_scale=integration_max_step_scale,
|
|
4344
|
+
integration_max_error_scale=integration_max_error_scale,
|
|
4345
|
+
num_arrows=num_arrows,
|
|
4346
|
+
**({"data": data} if data is not None else {}),
|
|
4347
|
+
)
|
|
4348
|
+
sci(__ret.lines)
|
|
4349
|
+
return __ret
|
|
4350
|
+
|
|
4351
|
+
|
|
4352
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
4353
|
+
@_copy_docstring_and_deprecators(Axes.table)
|
|
4354
|
+
def table(
|
|
4355
|
+
cellText=None,
|
|
4356
|
+
cellColours=None,
|
|
4357
|
+
cellLoc="right",
|
|
4358
|
+
colWidths=None,
|
|
4359
|
+
rowLabels=None,
|
|
4360
|
+
rowColours=None,
|
|
4361
|
+
rowLoc="left",
|
|
4362
|
+
colLabels=None,
|
|
4363
|
+
colColours=None,
|
|
4364
|
+
colLoc="center",
|
|
4365
|
+
loc="bottom",
|
|
4366
|
+
bbox=None,
|
|
4367
|
+
edges="closed",
|
|
4368
|
+
**kwargs,
|
|
4369
|
+
):
|
|
4370
|
+
return gca().table(
|
|
4371
|
+
cellText=cellText,
|
|
4372
|
+
cellColours=cellColours,
|
|
4373
|
+
cellLoc=cellLoc,
|
|
4374
|
+
colWidths=colWidths,
|
|
4375
|
+
rowLabels=rowLabels,
|
|
4376
|
+
rowColours=rowColours,
|
|
4377
|
+
rowLoc=rowLoc,
|
|
4378
|
+
colLabels=colLabels,
|
|
4379
|
+
colColours=colColours,
|
|
4380
|
+
colLoc=colLoc,
|
|
4381
|
+
loc=loc,
|
|
4382
|
+
bbox=bbox,
|
|
4383
|
+
edges=edges,
|
|
4384
|
+
**kwargs,
|
|
4385
|
+
)
|
|
4386
|
+
|
|
4387
|
+
|
|
4388
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
4389
|
+
@_copy_docstring_and_deprecators(Axes.text)
|
|
4390
|
+
def text(
|
|
4391
|
+
x: float, y: float, s: str, fontdict: dict[str, Any] | None = None, **kwargs
|
|
4392
|
+
) -> Text:
|
|
4393
|
+
return gca().text(x, y, s, fontdict=fontdict, **kwargs)
|
|
4394
|
+
|
|
4395
|
+
|
|
4396
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
4397
|
+
@_copy_docstring_and_deprecators(Axes.tick_params)
|
|
4398
|
+
def tick_params(axis: Literal["both", "x", "y"] = "both", **kwargs) -> None:
|
|
4399
|
+
gca().tick_params(axis=axis, **kwargs)
|
|
4400
|
+
|
|
4401
|
+
|
|
4402
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
4403
|
+
@_copy_docstring_and_deprecators(Axes.ticklabel_format)
|
|
4404
|
+
def ticklabel_format(
|
|
4405
|
+
*,
|
|
4406
|
+
axis: Literal["both", "x", "y"] = "both",
|
|
4407
|
+
style: Literal["", "sci", "scientific", "plain"] | None = None,
|
|
4408
|
+
scilimits: tuple[int, int] | None = None,
|
|
4409
|
+
useOffset: bool | float | None = None,
|
|
4410
|
+
useLocale: bool | None = None,
|
|
4411
|
+
useMathText: bool | None = None,
|
|
4412
|
+
) -> None:
|
|
4413
|
+
gca().ticklabel_format(
|
|
4414
|
+
axis=axis,
|
|
4415
|
+
style=style,
|
|
4416
|
+
scilimits=scilimits,
|
|
4417
|
+
useOffset=useOffset,
|
|
4418
|
+
useLocale=useLocale,
|
|
4419
|
+
useMathText=useMathText,
|
|
4420
|
+
)
|
|
4421
|
+
|
|
4422
|
+
|
|
4423
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
4424
|
+
@_copy_docstring_and_deprecators(Axes.tricontour)
|
|
4425
|
+
def tricontour(*args, **kwargs):
|
|
4426
|
+
__ret = gca().tricontour(*args, **kwargs)
|
|
4427
|
+
if __ret._A is not None: # type: ignore[attr-defined]
|
|
4428
|
+
sci(__ret)
|
|
4429
|
+
return __ret
|
|
4430
|
+
|
|
4431
|
+
|
|
4432
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
4433
|
+
@_copy_docstring_and_deprecators(Axes.tricontourf)
|
|
4434
|
+
def tricontourf(*args, **kwargs):
|
|
4435
|
+
__ret = gca().tricontourf(*args, **kwargs)
|
|
4436
|
+
if __ret._A is not None: # type: ignore[attr-defined]
|
|
4437
|
+
sci(__ret)
|
|
4438
|
+
return __ret
|
|
4439
|
+
|
|
4440
|
+
|
|
4441
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
4442
|
+
@_copy_docstring_and_deprecators(Axes.tripcolor)
|
|
4443
|
+
def tripcolor(
|
|
4444
|
+
*args,
|
|
4445
|
+
alpha=1.0,
|
|
4446
|
+
norm=None,
|
|
4447
|
+
cmap=None,
|
|
4448
|
+
vmin=None,
|
|
4449
|
+
vmax=None,
|
|
4450
|
+
shading="flat",
|
|
4451
|
+
facecolors=None,
|
|
4452
|
+
**kwargs,
|
|
4453
|
+
):
|
|
4454
|
+
__ret = gca().tripcolor(
|
|
4455
|
+
*args,
|
|
4456
|
+
alpha=alpha,
|
|
4457
|
+
norm=norm,
|
|
4458
|
+
cmap=cmap,
|
|
4459
|
+
vmin=vmin,
|
|
4460
|
+
vmax=vmax,
|
|
4461
|
+
shading=shading,
|
|
4462
|
+
facecolors=facecolors,
|
|
4463
|
+
**kwargs,
|
|
4464
|
+
)
|
|
4465
|
+
sci(__ret)
|
|
4466
|
+
return __ret
|
|
4467
|
+
|
|
4468
|
+
|
|
4469
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
4470
|
+
@_copy_docstring_and_deprecators(Axes.triplot)
|
|
4471
|
+
def triplot(*args, **kwargs):
|
|
4472
|
+
return gca().triplot(*args, **kwargs)
|
|
4473
|
+
|
|
4474
|
+
|
|
4475
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
4476
|
+
@_copy_docstring_and_deprecators(Axes.violinplot)
|
|
4477
|
+
def violinplot(
|
|
4478
|
+
dataset: ArrayLike | Sequence[ArrayLike],
|
|
4479
|
+
positions: ArrayLike | None = None,
|
|
4480
|
+
vert: bool | None = None,
|
|
4481
|
+
orientation: Literal["vertical", "horizontal"] = "vertical",
|
|
4482
|
+
widths: float | ArrayLike = 0.5,
|
|
4483
|
+
showmeans: bool = False,
|
|
4484
|
+
showextrema: bool = True,
|
|
4485
|
+
showmedians: bool = False,
|
|
4486
|
+
quantiles: Sequence[float | Sequence[float]] | None = None,
|
|
4487
|
+
points: int = 100,
|
|
4488
|
+
bw_method: (
|
|
4489
|
+
Literal["scott", "silverman"] | float | Callable[[GaussianKDE], float] | None
|
|
4490
|
+
) = None,
|
|
4491
|
+
side: Literal["both", "low", "high"] = "both",
|
|
4492
|
+
facecolor: Sequence[ColorType] | ColorType | None = None,
|
|
4493
|
+
linecolor: Sequence[ColorType] | ColorType | None = None,
|
|
4494
|
+
*,
|
|
4495
|
+
data: DataParamType = None,
|
|
4496
|
+
) -> dict[str, Collection]:
|
|
4497
|
+
return gca().violinplot(
|
|
4498
|
+
dataset,
|
|
4499
|
+
positions=positions,
|
|
4500
|
+
vert=vert,
|
|
4501
|
+
orientation=orientation,
|
|
4502
|
+
widths=widths,
|
|
4503
|
+
showmeans=showmeans,
|
|
4504
|
+
showextrema=showextrema,
|
|
4505
|
+
showmedians=showmedians,
|
|
4506
|
+
quantiles=quantiles,
|
|
4507
|
+
points=points,
|
|
4508
|
+
bw_method=bw_method,
|
|
4509
|
+
side=side,
|
|
4510
|
+
facecolor=facecolor,
|
|
4511
|
+
linecolor=linecolor,
|
|
4512
|
+
**({"data": data} if data is not None else {}),
|
|
4513
|
+
)
|
|
4514
|
+
|
|
4515
|
+
|
|
4516
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
4517
|
+
@_copy_docstring_and_deprecators(Axes.vlines)
|
|
4518
|
+
def vlines(
|
|
4519
|
+
x: float | ArrayLike,
|
|
4520
|
+
ymin: float | ArrayLike,
|
|
4521
|
+
ymax: float | ArrayLike,
|
|
4522
|
+
colors: ColorType | Sequence[ColorType] | None = None,
|
|
4523
|
+
linestyles: LineStyleType = "solid",
|
|
4524
|
+
label: str = "",
|
|
4525
|
+
*,
|
|
4526
|
+
data: DataParamType = None,
|
|
4527
|
+
**kwargs,
|
|
4528
|
+
) -> LineCollection:
|
|
4529
|
+
return gca().vlines(
|
|
4530
|
+
x,
|
|
4531
|
+
ymin,
|
|
4532
|
+
ymax,
|
|
4533
|
+
colors=colors,
|
|
4534
|
+
linestyles=linestyles,
|
|
4535
|
+
label=label,
|
|
4536
|
+
**({"data": data} if data is not None else {}),
|
|
4537
|
+
**kwargs,
|
|
4538
|
+
)
|
|
4539
|
+
|
|
4540
|
+
|
|
4541
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
4542
|
+
@_copy_docstring_and_deprecators(Axes.xcorr)
|
|
4543
|
+
def xcorr(
|
|
4544
|
+
x: ArrayLike,
|
|
4545
|
+
y: ArrayLike,
|
|
4546
|
+
normed: bool = True,
|
|
4547
|
+
detrend: Callable[[ArrayLike], ArrayLike] = mlab.detrend_none,
|
|
4548
|
+
usevlines: bool = True,
|
|
4549
|
+
maxlags: int = 10,
|
|
4550
|
+
*,
|
|
4551
|
+
data: DataParamType = None,
|
|
4552
|
+
**kwargs,
|
|
4553
|
+
) -> tuple[np.ndarray, np.ndarray, LineCollection | Line2D, Line2D | None]:
|
|
4554
|
+
return gca().xcorr(
|
|
4555
|
+
x,
|
|
4556
|
+
y,
|
|
4557
|
+
normed=normed,
|
|
4558
|
+
detrend=detrend,
|
|
4559
|
+
usevlines=usevlines,
|
|
4560
|
+
maxlags=maxlags,
|
|
4561
|
+
**({"data": data} if data is not None else {}),
|
|
4562
|
+
**kwargs,
|
|
4563
|
+
)
|
|
4564
|
+
|
|
4565
|
+
|
|
4566
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
4567
|
+
@_copy_docstring_and_deprecators(Axes._sci)
|
|
4568
|
+
def sci(im: ColorizingArtist) -> None:
|
|
4569
|
+
gca()._sci(im)
|
|
4570
|
+
|
|
4571
|
+
|
|
4572
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
4573
|
+
@_copy_docstring_and_deprecators(Axes.set_title)
|
|
4574
|
+
def title(
|
|
4575
|
+
label: str,
|
|
4576
|
+
fontdict: dict[str, Any] | None = None,
|
|
4577
|
+
loc: Literal["left", "center", "right"] | None = None,
|
|
4578
|
+
pad: float | None = None,
|
|
4579
|
+
*,
|
|
4580
|
+
y: float | None = None,
|
|
4581
|
+
**kwargs,
|
|
4582
|
+
) -> Text:
|
|
4583
|
+
return gca().set_title(label, fontdict=fontdict, loc=loc, pad=pad, y=y, **kwargs)
|
|
4584
|
+
|
|
4585
|
+
|
|
4586
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
4587
|
+
@_copy_docstring_and_deprecators(Axes.set_xlabel)
|
|
4588
|
+
def xlabel(
|
|
4589
|
+
xlabel: str,
|
|
4590
|
+
fontdict: dict[str, Any] | None = None,
|
|
4591
|
+
labelpad: float | None = None,
|
|
4592
|
+
*,
|
|
4593
|
+
loc: Literal["left", "center", "right"] | None = None,
|
|
4594
|
+
**kwargs,
|
|
4595
|
+
) -> Text:
|
|
4596
|
+
return gca().set_xlabel(
|
|
4597
|
+
xlabel, fontdict=fontdict, labelpad=labelpad, loc=loc, **kwargs
|
|
4598
|
+
)
|
|
4599
|
+
|
|
4600
|
+
|
|
4601
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
4602
|
+
@_copy_docstring_and_deprecators(Axes.set_ylabel)
|
|
4603
|
+
def ylabel(
|
|
4604
|
+
ylabel: str,
|
|
4605
|
+
fontdict: dict[str, Any] | None = None,
|
|
4606
|
+
labelpad: float | None = None,
|
|
4607
|
+
*,
|
|
4608
|
+
loc: Literal["bottom", "center", "top"] | None = None,
|
|
4609
|
+
**kwargs,
|
|
4610
|
+
) -> Text:
|
|
4611
|
+
return gca().set_ylabel(
|
|
4612
|
+
ylabel, fontdict=fontdict, labelpad=labelpad, loc=loc, **kwargs
|
|
4613
|
+
)
|
|
4614
|
+
|
|
4615
|
+
|
|
4616
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
4617
|
+
@_copy_docstring_and_deprecators(Axes.set_xscale)
|
|
4618
|
+
def xscale(value: str | ScaleBase, **kwargs) -> None:
|
|
4619
|
+
gca().set_xscale(value, **kwargs)
|
|
4620
|
+
|
|
4621
|
+
|
|
4622
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
4623
|
+
@_copy_docstring_and_deprecators(Axes.set_yscale)
|
|
4624
|
+
def yscale(value: str | ScaleBase, **kwargs) -> None:
|
|
4625
|
+
gca().set_yscale(value, **kwargs)
|
|
4626
|
+
|
|
4627
|
+
|
|
4628
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
4629
|
+
def autumn() -> None:
|
|
4630
|
+
"""
|
|
4631
|
+
Set the colormap to 'autumn'.
|
|
4632
|
+
|
|
4633
|
+
This changes the default colormap as well as the colormap of the current
|
|
4634
|
+
image if there is one. See ``help(colormaps)`` for more information.
|
|
4635
|
+
"""
|
|
4636
|
+
set_cmap("autumn")
|
|
4637
|
+
|
|
4638
|
+
|
|
4639
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
4640
|
+
def bone() -> None:
|
|
4641
|
+
"""
|
|
4642
|
+
Set the colormap to 'bone'.
|
|
4643
|
+
|
|
4644
|
+
This changes the default colormap as well as the colormap of the current
|
|
4645
|
+
image if there is one. See ``help(colormaps)`` for more information.
|
|
4646
|
+
"""
|
|
4647
|
+
set_cmap("bone")
|
|
4648
|
+
|
|
4649
|
+
|
|
4650
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
4651
|
+
def cool() -> None:
|
|
4652
|
+
"""
|
|
4653
|
+
Set the colormap to 'cool'.
|
|
4654
|
+
|
|
4655
|
+
This changes the default colormap as well as the colormap of the current
|
|
4656
|
+
image if there is one. See ``help(colormaps)`` for more information.
|
|
4657
|
+
"""
|
|
4658
|
+
set_cmap("cool")
|
|
4659
|
+
|
|
4660
|
+
|
|
4661
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
4662
|
+
def copper() -> None:
|
|
4663
|
+
"""
|
|
4664
|
+
Set the colormap to 'copper'.
|
|
4665
|
+
|
|
4666
|
+
This changes the default colormap as well as the colormap of the current
|
|
4667
|
+
image if there is one. See ``help(colormaps)`` for more information.
|
|
4668
|
+
"""
|
|
4669
|
+
set_cmap("copper")
|
|
4670
|
+
|
|
4671
|
+
|
|
4672
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
4673
|
+
def flag() -> None:
|
|
4674
|
+
"""
|
|
4675
|
+
Set the colormap to 'flag'.
|
|
4676
|
+
|
|
4677
|
+
This changes the default colormap as well as the colormap of the current
|
|
4678
|
+
image if there is one. See ``help(colormaps)`` for more information.
|
|
4679
|
+
"""
|
|
4680
|
+
set_cmap("flag")
|
|
4681
|
+
|
|
4682
|
+
|
|
4683
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
4684
|
+
def gray() -> None:
|
|
4685
|
+
"""
|
|
4686
|
+
Set the colormap to 'gray'.
|
|
4687
|
+
|
|
4688
|
+
This changes the default colormap as well as the colormap of the current
|
|
4689
|
+
image if there is one. See ``help(colormaps)`` for more information.
|
|
4690
|
+
"""
|
|
4691
|
+
set_cmap("gray")
|
|
4692
|
+
|
|
4693
|
+
|
|
4694
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
4695
|
+
def hot() -> None:
|
|
4696
|
+
"""
|
|
4697
|
+
Set the colormap to 'hot'.
|
|
4698
|
+
|
|
4699
|
+
This changes the default colormap as well as the colormap of the current
|
|
4700
|
+
image if there is one. See ``help(colormaps)`` for more information.
|
|
4701
|
+
"""
|
|
4702
|
+
set_cmap("hot")
|
|
4703
|
+
|
|
4704
|
+
|
|
4705
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
4706
|
+
def hsv() -> None:
|
|
4707
|
+
"""
|
|
4708
|
+
Set the colormap to 'hsv'.
|
|
4709
|
+
|
|
4710
|
+
This changes the default colormap as well as the colormap of the current
|
|
4711
|
+
image if there is one. See ``help(colormaps)`` for more information.
|
|
4712
|
+
"""
|
|
4713
|
+
set_cmap("hsv")
|
|
4714
|
+
|
|
4715
|
+
|
|
4716
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
4717
|
+
def jet() -> None:
|
|
4718
|
+
"""
|
|
4719
|
+
Set the colormap to 'jet'.
|
|
4720
|
+
|
|
4721
|
+
This changes the default colormap as well as the colormap of the current
|
|
4722
|
+
image if there is one. See ``help(colormaps)`` for more information.
|
|
4723
|
+
"""
|
|
4724
|
+
set_cmap("jet")
|
|
4725
|
+
|
|
4726
|
+
|
|
4727
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
4728
|
+
def pink() -> None:
|
|
4729
|
+
"""
|
|
4730
|
+
Set the colormap to 'pink'.
|
|
4731
|
+
|
|
4732
|
+
This changes the default colormap as well as the colormap of the current
|
|
4733
|
+
image if there is one. See ``help(colormaps)`` for more information.
|
|
4734
|
+
"""
|
|
4735
|
+
set_cmap("pink")
|
|
4736
|
+
|
|
4737
|
+
|
|
4738
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
4739
|
+
def prism() -> None:
|
|
4740
|
+
"""
|
|
4741
|
+
Set the colormap to 'prism'.
|
|
4742
|
+
|
|
4743
|
+
This changes the default colormap as well as the colormap of the current
|
|
4744
|
+
image if there is one. See ``help(colormaps)`` for more information.
|
|
4745
|
+
"""
|
|
4746
|
+
set_cmap("prism")
|
|
4747
|
+
|
|
4748
|
+
|
|
4749
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
4750
|
+
def spring() -> None:
|
|
4751
|
+
"""
|
|
4752
|
+
Set the colormap to 'spring'.
|
|
4753
|
+
|
|
4754
|
+
This changes the default colormap as well as the colormap of the current
|
|
4755
|
+
image if there is one. See ``help(colormaps)`` for more information.
|
|
4756
|
+
"""
|
|
4757
|
+
set_cmap("spring")
|
|
4758
|
+
|
|
4759
|
+
|
|
4760
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
4761
|
+
def summer() -> None:
|
|
4762
|
+
"""
|
|
4763
|
+
Set the colormap to 'summer'.
|
|
4764
|
+
|
|
4765
|
+
This changes the default colormap as well as the colormap of the current
|
|
4766
|
+
image if there is one. See ``help(colormaps)`` for more information.
|
|
4767
|
+
"""
|
|
4768
|
+
set_cmap("summer")
|
|
4769
|
+
|
|
4770
|
+
|
|
4771
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
4772
|
+
def winter() -> None:
|
|
4773
|
+
"""
|
|
4774
|
+
Set the colormap to 'winter'.
|
|
4775
|
+
|
|
4776
|
+
This changes the default colormap as well as the colormap of the current
|
|
4777
|
+
image if there is one. See ``help(colormaps)`` for more information.
|
|
4778
|
+
"""
|
|
4779
|
+
set_cmap("winter")
|
|
4780
|
+
|
|
4781
|
+
|
|
4782
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
4783
|
+
def magma() -> None:
|
|
4784
|
+
"""
|
|
4785
|
+
Set the colormap to 'magma'.
|
|
4786
|
+
|
|
4787
|
+
This changes the default colormap as well as the colormap of the current
|
|
4788
|
+
image if there is one. See ``help(colormaps)`` for more information.
|
|
4789
|
+
"""
|
|
4790
|
+
set_cmap("magma")
|
|
4791
|
+
|
|
4792
|
+
|
|
4793
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
4794
|
+
def inferno() -> None:
|
|
4795
|
+
"""
|
|
4796
|
+
Set the colormap to 'inferno'.
|
|
4797
|
+
|
|
4798
|
+
This changes the default colormap as well as the colormap of the current
|
|
4799
|
+
image if there is one. See ``help(colormaps)`` for more information.
|
|
4800
|
+
"""
|
|
4801
|
+
set_cmap("inferno")
|
|
4802
|
+
|
|
4803
|
+
|
|
4804
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
4805
|
+
def plasma() -> None:
|
|
4806
|
+
"""
|
|
4807
|
+
Set the colormap to 'plasma'.
|
|
4808
|
+
|
|
4809
|
+
This changes the default colormap as well as the colormap of the current
|
|
4810
|
+
image if there is one. See ``help(colormaps)`` for more information.
|
|
4811
|
+
"""
|
|
4812
|
+
set_cmap("plasma")
|
|
4813
|
+
|
|
4814
|
+
|
|
4815
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
4816
|
+
def viridis() -> None:
|
|
4817
|
+
"""
|
|
4818
|
+
Set the colormap to 'viridis'.
|
|
4819
|
+
|
|
4820
|
+
This changes the default colormap as well as the colormap of the current
|
|
4821
|
+
image if there is one. See ``help(colormaps)`` for more information.
|
|
4822
|
+
"""
|
|
4823
|
+
set_cmap("viridis")
|
|
4824
|
+
|
|
4825
|
+
|
|
4826
|
+
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
|
|
4827
|
+
def nipy_spectral() -> None:
|
|
4828
|
+
"""
|
|
4829
|
+
Set the colormap to 'nipy_spectral'.
|
|
4830
|
+
|
|
4831
|
+
This changes the default colormap as well as the colormap of the current
|
|
4832
|
+
image if there is one. See ``help(colormaps)`` for more information.
|
|
4833
|
+
"""
|
|
4834
|
+
set_cmap("nipy_spectral")
|