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
|
@@ -0,0 +1,1518 @@
|
|
|
1
|
+
# Vendored from matplotlib 3.11 (see licenses/LICENSE_MATPLOTLIB), adapted for matplotlib_rs.
|
|
2
|
+
import math
|
|
3
|
+
import types
|
|
4
|
+
|
|
5
|
+
import numpy as np
|
|
6
|
+
|
|
7
|
+
import matplotlib_rs as mpl
|
|
8
|
+
from matplotlib_rs import _api, cbook
|
|
9
|
+
from matplotlib_rs.axes import Axes
|
|
10
|
+
import matplotlib_rs._axis_py as maxis
|
|
11
|
+
import matplotlib_rs.markers as mmarkers
|
|
12
|
+
import matplotlib_rs.patches as mpatches
|
|
13
|
+
from matplotlib_rs.path import Path
|
|
14
|
+
import matplotlib_rs.ticker as mticker
|
|
15
|
+
import matplotlib_rs.transforms as mtransforms
|
|
16
|
+
from matplotlib_rs.spines import Spine
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class PolarTransform(mtransforms.Transform):
|
|
20
|
+
r"""
|
|
21
|
+
The base polar transform.
|
|
22
|
+
|
|
23
|
+
This transform maps polar coordinates :math:`\theta, r` into Cartesian
|
|
24
|
+
coordinates :math:`x, y = r \cos(\theta), r \sin(\theta)`
|
|
25
|
+
(but does not fully transform into Axes coordinates or
|
|
26
|
+
handle positioning in screen space).
|
|
27
|
+
|
|
28
|
+
This transformation is designed to be applied to data after any scaling
|
|
29
|
+
along the radial axis (e.g. log-scaling) has been applied to the input
|
|
30
|
+
data.
|
|
31
|
+
|
|
32
|
+
Path segments at a fixed radius are automatically transformed to circular
|
|
33
|
+
arcs as long as ``path._interpolation_steps > 1``.
|
|
34
|
+
"""
|
|
35
|
+
|
|
36
|
+
input_dims = output_dims = 2
|
|
37
|
+
|
|
38
|
+
@_api.delete_parameter('3.11', 'apply_theta_transforms')
|
|
39
|
+
def __init__(self, axis=None, use_rmin=True, *,
|
|
40
|
+
apply_theta_transforms=False, scale_transform=None):
|
|
41
|
+
"""
|
|
42
|
+
Parameters
|
|
43
|
+
----------
|
|
44
|
+
axis : `~matplotlib.axis.Axis`, optional
|
|
45
|
+
Axis associated with this transform. This is used to get the
|
|
46
|
+
minimum radial limit.
|
|
47
|
+
use_rmin : `bool`, optional
|
|
48
|
+
If ``True``, subtract the minimum radial axis limit before
|
|
49
|
+
transforming to Cartesian coordinates. *axis* must also be
|
|
50
|
+
specified for this to take effect.
|
|
51
|
+
"""
|
|
52
|
+
super().__init__()
|
|
53
|
+
self._axis = axis
|
|
54
|
+
self._use_rmin = use_rmin
|
|
55
|
+
self._scale_transform = scale_transform
|
|
56
|
+
|
|
57
|
+
__str__ = mtransforms._make_str_method(
|
|
58
|
+
"_axis",
|
|
59
|
+
use_rmin="_use_rmin"
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
def _get_rorigin(self):
|
|
63
|
+
# Get lower r limit after being scaled by the radial scale transform
|
|
64
|
+
return self._scale_transform.transform(
|
|
65
|
+
(0, self._axis.get_rorigin()))[1]
|
|
66
|
+
|
|
67
|
+
def transform_non_affine(self, values):
|
|
68
|
+
# docstring inherited
|
|
69
|
+
theta, r = np.transpose(values)
|
|
70
|
+
if self._use_rmin and self._axis is not None:
|
|
71
|
+
r = (r - self._get_rorigin()) * self._axis.get_rsign()
|
|
72
|
+
r = np.where(r >= 0, r, np.nan)
|
|
73
|
+
return np.column_stack([r * np.cos(theta), r * np.sin(theta)])
|
|
74
|
+
|
|
75
|
+
def transform_path_non_affine(self, path):
|
|
76
|
+
# docstring inherited
|
|
77
|
+
if not len(path) or path._interpolation_steps == 1:
|
|
78
|
+
return Path(self.transform_non_affine(path.vertices), path.codes)
|
|
79
|
+
xys = []
|
|
80
|
+
codes = []
|
|
81
|
+
last_t = last_r = None
|
|
82
|
+
for trs, c in path.iter_segments():
|
|
83
|
+
trs = trs.reshape((-1, 2))
|
|
84
|
+
if c == Path.LINETO:
|
|
85
|
+
(t, r), = trs
|
|
86
|
+
if t == last_t: # Same angle: draw a straight line.
|
|
87
|
+
xys.extend(self.transform_non_affine(trs))
|
|
88
|
+
codes.append(Path.LINETO)
|
|
89
|
+
elif r == last_r: # Same radius: draw an arc.
|
|
90
|
+
# The following is complicated by Path.arc() being
|
|
91
|
+
# "helpful" and unwrapping the angles, but we don't want
|
|
92
|
+
# that behavior here.
|
|
93
|
+
last_td, td = np.rad2deg([last_t, t])
|
|
94
|
+
if self._use_rmin and self._axis is not None:
|
|
95
|
+
r = ((r - self._get_rorigin())
|
|
96
|
+
* self._axis.get_rsign())
|
|
97
|
+
if last_td <= td:
|
|
98
|
+
while td - last_td > 360:
|
|
99
|
+
arc = Path.arc(last_td, last_td + 360)
|
|
100
|
+
xys.extend(arc.vertices[1:] * r)
|
|
101
|
+
codes.extend(arc.codes[1:])
|
|
102
|
+
last_td += 360
|
|
103
|
+
arc = Path.arc(last_td, td)
|
|
104
|
+
xys.extend(arc.vertices[1:] * r)
|
|
105
|
+
codes.extend(arc.codes[1:])
|
|
106
|
+
else:
|
|
107
|
+
# The reverse version also relies on the fact that all
|
|
108
|
+
# codes but the first one are the same.
|
|
109
|
+
while last_td - td > 360:
|
|
110
|
+
arc = Path.arc(last_td - 360, last_td)
|
|
111
|
+
xys.extend(arc.vertices[::-1][1:] * r)
|
|
112
|
+
codes.extend(arc.codes[1:])
|
|
113
|
+
last_td -= 360
|
|
114
|
+
arc = Path.arc(td, last_td)
|
|
115
|
+
xys.extend(arc.vertices[::-1][1:] * r)
|
|
116
|
+
codes.extend(arc.codes[1:])
|
|
117
|
+
else: # Interpolate.
|
|
118
|
+
trs = cbook.simple_linear_interpolation(
|
|
119
|
+
np.vstack([(last_t, last_r), trs]),
|
|
120
|
+
path._interpolation_steps)[1:]
|
|
121
|
+
xys.extend(self.transform_non_affine(trs))
|
|
122
|
+
codes.extend([Path.LINETO] * len(trs))
|
|
123
|
+
else: # Not a straight line.
|
|
124
|
+
xys.extend(self.transform_non_affine(trs))
|
|
125
|
+
codes.extend([c] * len(trs))
|
|
126
|
+
last_t, last_r = trs[-1]
|
|
127
|
+
return Path(xys, codes)
|
|
128
|
+
|
|
129
|
+
def inverted(self):
|
|
130
|
+
# docstring inherited
|
|
131
|
+
return PolarAxes.InvertedPolarTransform(self._axis, self._use_rmin)
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
class PolarAffine(mtransforms.Affine2DBase):
|
|
135
|
+
r"""
|
|
136
|
+
The affine part of the polar projection.
|
|
137
|
+
|
|
138
|
+
Scales the output so that maximum radius rests on the edge of the Axes
|
|
139
|
+
circle and the origin is mapped to (0.5, 0.5). The transform applied is
|
|
140
|
+
the same to x and y components and given by:
|
|
141
|
+
|
|
142
|
+
.. math::
|
|
143
|
+
|
|
144
|
+
x_{1} = 0.5 \left [ \frac{x_{0}}{(r_{\max} - r_{\min})} + 1 \right ]
|
|
145
|
+
|
|
146
|
+
:math:`r_{\min}, r_{\max}` are the minimum and maximum radial limits after
|
|
147
|
+
any scaling (e.g. log scaling) has been removed.
|
|
148
|
+
"""
|
|
149
|
+
def __init__(self, scale_transform, limits):
|
|
150
|
+
"""
|
|
151
|
+
Parameters
|
|
152
|
+
----------
|
|
153
|
+
scale_transform : `~matplotlib.transforms.Transform`
|
|
154
|
+
Scaling transform for the data. This is used to remove any scaling
|
|
155
|
+
from the radial view limits.
|
|
156
|
+
limits : `~matplotlib.transforms.BboxBase`
|
|
157
|
+
View limits of the data. The only part of its bounds that is used
|
|
158
|
+
is the y limits (for the radius limits).
|
|
159
|
+
"""
|
|
160
|
+
super().__init__()
|
|
161
|
+
self._scale_transform = scale_transform
|
|
162
|
+
self._limits = limits
|
|
163
|
+
self.set_children(scale_transform, limits)
|
|
164
|
+
self._mtx = None
|
|
165
|
+
|
|
166
|
+
__str__ = mtransforms._make_str_method("_scale_transform", "_limits")
|
|
167
|
+
|
|
168
|
+
def get_matrix(self):
|
|
169
|
+
# docstring inherited
|
|
170
|
+
if self._invalid:
|
|
171
|
+
limits_scaled = self._limits.transformed(self._scale_transform)
|
|
172
|
+
yscale = limits_scaled.ymax - limits_scaled.ymin
|
|
173
|
+
affine = mtransforms.Affine2D() \
|
|
174
|
+
.scale(0.5 / yscale) \
|
|
175
|
+
.translate(0.5, 0.5)
|
|
176
|
+
self._mtx = affine.get_matrix()
|
|
177
|
+
self._inverted = None
|
|
178
|
+
self._invalid = 0
|
|
179
|
+
return self._mtx
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
class InvertedPolarTransform(mtransforms.Transform):
|
|
183
|
+
"""
|
|
184
|
+
The inverse of the polar transform, mapping Cartesian
|
|
185
|
+
coordinate space *x* and *y* back to *theta* and *r*.
|
|
186
|
+
"""
|
|
187
|
+
input_dims = output_dims = 2
|
|
188
|
+
|
|
189
|
+
@_api.delete_parameter('3.11', 'apply_theta_transforms')
|
|
190
|
+
def __init__(self, axis=None, use_rmin=True,
|
|
191
|
+
*, apply_theta_transforms=False):
|
|
192
|
+
"""
|
|
193
|
+
Parameters
|
|
194
|
+
----------
|
|
195
|
+
axis : `~matplotlib.axis.Axis`, optional
|
|
196
|
+
Axis associated with this transform. This is used to get the
|
|
197
|
+
minimum radial limit.
|
|
198
|
+
use_rmin : `bool`, optional
|
|
199
|
+
If ``True``, add the minimum radial axis limit after
|
|
200
|
+
transforming from Cartesian coordinates. *axis* must also be
|
|
201
|
+
specified for this to take effect.
|
|
202
|
+
"""
|
|
203
|
+
super().__init__()
|
|
204
|
+
self._axis = axis
|
|
205
|
+
self._use_rmin = use_rmin
|
|
206
|
+
|
|
207
|
+
__str__ = mtransforms._make_str_method(
|
|
208
|
+
"_axis",
|
|
209
|
+
use_rmin="_use_rmin")
|
|
210
|
+
|
|
211
|
+
def transform_non_affine(self, values):
|
|
212
|
+
# docstring inherited
|
|
213
|
+
x, y = values.T
|
|
214
|
+
r = np.hypot(x, y)
|
|
215
|
+
theta = np.arctan2(y, x) % (2 * np.pi)
|
|
216
|
+
if self._use_rmin and self._axis is not None:
|
|
217
|
+
r += self._axis.get_rorigin()
|
|
218
|
+
r *= self._axis.get_rsign()
|
|
219
|
+
return np.column_stack([theta, r])
|
|
220
|
+
|
|
221
|
+
def inverted(self):
|
|
222
|
+
# docstring inherited
|
|
223
|
+
return PolarAxes.PolarTransform(self._axis, self._use_rmin)
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
class ThetaFormatter(mticker.Formatter):
|
|
227
|
+
"""
|
|
228
|
+
Used to format the *theta* tick labels. Converts the native
|
|
229
|
+
unit of radians into degrees and adds a degree symbol.
|
|
230
|
+
"""
|
|
231
|
+
|
|
232
|
+
def __call__(self, x, pos=None):
|
|
233
|
+
vmin, vmax = self.axis.get_view_interval()
|
|
234
|
+
d = np.rad2deg(abs(vmax - vmin))
|
|
235
|
+
digits = max(-int(np.log10(d) - 1.5), 0)
|
|
236
|
+
return f"{np.rad2deg(x):0.{digits}f}\N{DEGREE SIGN}"
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
class _AxisWrapper:
|
|
240
|
+
def __init__(self, axis):
|
|
241
|
+
self._axis = axis
|
|
242
|
+
|
|
243
|
+
def get_view_interval(self):
|
|
244
|
+
return np.rad2deg(self._axis.get_view_interval())
|
|
245
|
+
|
|
246
|
+
def set_view_interval(self, vmin, vmax):
|
|
247
|
+
self._axis.set_view_interval(*np.deg2rad((vmin, vmax)))
|
|
248
|
+
|
|
249
|
+
def get_minpos(self):
|
|
250
|
+
return np.rad2deg(self._axis.get_minpos())
|
|
251
|
+
|
|
252
|
+
def get_data_interval(self):
|
|
253
|
+
return np.rad2deg(self._axis.get_data_interval())
|
|
254
|
+
|
|
255
|
+
def set_data_interval(self, vmin, vmax):
|
|
256
|
+
self._axis.set_data_interval(*np.deg2rad((vmin, vmax)))
|
|
257
|
+
|
|
258
|
+
def get_tick_space(self):
|
|
259
|
+
return self._axis.get_tick_space()
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
class ThetaLocator(mticker.Locator):
|
|
263
|
+
"""
|
|
264
|
+
Used to locate theta ticks.
|
|
265
|
+
|
|
266
|
+
This will work the same as the base locator except in the case that the
|
|
267
|
+
view spans the entire circle. In such cases, the previously used default
|
|
268
|
+
locations of every 45 degrees are returned.
|
|
269
|
+
"""
|
|
270
|
+
|
|
271
|
+
def __init__(self, base):
|
|
272
|
+
self.base = base
|
|
273
|
+
self.axis = self.base.axis = _AxisWrapper(self.base.axis)
|
|
274
|
+
|
|
275
|
+
def set_axis(self, axis):
|
|
276
|
+
self.axis = _AxisWrapper(axis)
|
|
277
|
+
self.base.set_axis(self.axis)
|
|
278
|
+
|
|
279
|
+
def __call__(self):
|
|
280
|
+
lim = self.axis.get_view_interval()
|
|
281
|
+
if _is_full_circle_deg(lim[0], lim[1]):
|
|
282
|
+
return np.deg2rad(min(lim)) + np.arange(8) * 2 * np.pi / 8
|
|
283
|
+
else:
|
|
284
|
+
return np.deg2rad(self.base())
|
|
285
|
+
|
|
286
|
+
def view_limits(self, vmin, vmax):
|
|
287
|
+
vmin, vmax = np.rad2deg((vmin, vmax))
|
|
288
|
+
return np.deg2rad(self.base.view_limits(vmin, vmax))
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
class ThetaTick(maxis.XTick):
|
|
292
|
+
"""
|
|
293
|
+
A theta-axis tick.
|
|
294
|
+
|
|
295
|
+
This subclass of `.XTick` provides angular ticks with some small
|
|
296
|
+
modification to their re-positioning such that ticks are rotated based on
|
|
297
|
+
tick location. This results in ticks that are correctly perpendicular to
|
|
298
|
+
the arc spine.
|
|
299
|
+
|
|
300
|
+
When 'auto' rotation is enabled, labels are also rotated to be parallel to
|
|
301
|
+
the spine. The label padding is also applied here since it's not possible
|
|
302
|
+
to use a generic axes transform to produce tick-specific padding.
|
|
303
|
+
"""
|
|
304
|
+
|
|
305
|
+
def __init__(self, axes, *args, **kwargs):
|
|
306
|
+
self._text1_translate = mtransforms.ScaledTranslation(
|
|
307
|
+
0, 0, axes.get_figure(root=False).dpi_scale_trans)
|
|
308
|
+
self._text2_translate = mtransforms.ScaledTranslation(
|
|
309
|
+
0, 0, axes.get_figure(root=False).dpi_scale_trans)
|
|
310
|
+
super().__init__(axes, *args, **kwargs)
|
|
311
|
+
self.label1.set(
|
|
312
|
+
rotation_mode='anchor',
|
|
313
|
+
transform=self.label1.get_transform() + self._text1_translate)
|
|
314
|
+
self.label2.set(
|
|
315
|
+
rotation_mode='anchor',
|
|
316
|
+
transform=self.label2.get_transform() + self._text2_translate)
|
|
317
|
+
|
|
318
|
+
def _apply_params(self, **kwargs):
|
|
319
|
+
super()._apply_params(**kwargs)
|
|
320
|
+
# Ensure transform is correct; sometimes this gets reset.
|
|
321
|
+
trans = self.label1.get_transform()
|
|
322
|
+
if not trans.contains_branch(self._text1_translate):
|
|
323
|
+
self.label1.set_transform(trans + self._text1_translate)
|
|
324
|
+
trans = self.label2.get_transform()
|
|
325
|
+
if not trans.contains_branch(self._text2_translate):
|
|
326
|
+
self.label2.set_transform(trans + self._text2_translate)
|
|
327
|
+
|
|
328
|
+
def _update_padding(self, pad, angle):
|
|
329
|
+
padx = pad * np.cos(angle) / 72
|
|
330
|
+
pady = pad * np.sin(angle) / 72
|
|
331
|
+
self._text1_translate._t = (padx, pady)
|
|
332
|
+
self._text1_translate.invalidate()
|
|
333
|
+
self._text2_translate._t = (-padx, -pady)
|
|
334
|
+
self._text2_translate.invalidate()
|
|
335
|
+
|
|
336
|
+
def update_position(self, loc):
|
|
337
|
+
super().update_position(loc)
|
|
338
|
+
axes = self.axes
|
|
339
|
+
angle = loc * axes.get_theta_direction() + axes.get_theta_offset()
|
|
340
|
+
text_angle = np.rad2deg(angle) % 360 - 90
|
|
341
|
+
angle -= np.pi / 2
|
|
342
|
+
|
|
343
|
+
marker = self.tick1line.get_marker()
|
|
344
|
+
if marker in (mmarkers.TICKUP, '|'):
|
|
345
|
+
trans = mtransforms.Affine2D().scale(1, 1).rotate(angle)
|
|
346
|
+
elif marker == mmarkers.TICKDOWN:
|
|
347
|
+
trans = mtransforms.Affine2D().scale(1, -1).rotate(angle)
|
|
348
|
+
else:
|
|
349
|
+
# Don't modify custom tick line markers.
|
|
350
|
+
trans = self.tick1line._marker._transform
|
|
351
|
+
self.tick1line._marker._transform = trans
|
|
352
|
+
|
|
353
|
+
marker = self.tick2line.get_marker()
|
|
354
|
+
if marker in (mmarkers.TICKUP, '|'):
|
|
355
|
+
trans = mtransforms.Affine2D().scale(1, 1).rotate(angle)
|
|
356
|
+
elif marker == mmarkers.TICKDOWN:
|
|
357
|
+
trans = mtransforms.Affine2D().scale(1, -1).rotate(angle)
|
|
358
|
+
else:
|
|
359
|
+
# Don't modify custom tick line markers.
|
|
360
|
+
trans = self.tick2line._marker._transform
|
|
361
|
+
self.tick2line._marker._transform = trans
|
|
362
|
+
|
|
363
|
+
mode, user_angle = self._labelrotation
|
|
364
|
+
if mode == 'default':
|
|
365
|
+
text_angle = user_angle
|
|
366
|
+
else:
|
|
367
|
+
if text_angle > 90:
|
|
368
|
+
text_angle -= 180
|
|
369
|
+
elif text_angle < -90:
|
|
370
|
+
text_angle += 180
|
|
371
|
+
text_angle += user_angle
|
|
372
|
+
self.label1.set_rotation(text_angle)
|
|
373
|
+
self.label2.set_rotation(text_angle)
|
|
374
|
+
|
|
375
|
+
# This extra padding helps preserve the look from previous releases but
|
|
376
|
+
# is also needed because labels are anchored to their center.
|
|
377
|
+
pad = self._pad + 7
|
|
378
|
+
self._update_padding(pad,
|
|
379
|
+
self._loc * axes.get_theta_direction() +
|
|
380
|
+
axes.get_theta_offset())
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
class ThetaAxis(maxis.XAxis):
|
|
384
|
+
"""
|
|
385
|
+
A theta Axis.
|
|
386
|
+
|
|
387
|
+
This overrides certain properties of an `.XAxis` to provide special-casing
|
|
388
|
+
for an angular axis.
|
|
389
|
+
"""
|
|
390
|
+
__name__ = 'thetaaxis'
|
|
391
|
+
axis_name = 'theta' #: Read-only name identifying the axis.
|
|
392
|
+
_tick_class = ThetaTick
|
|
393
|
+
|
|
394
|
+
def _wrap_locator_formatter(self):
|
|
395
|
+
self.set_major_locator(ThetaLocator(self.get_major_locator()))
|
|
396
|
+
self.set_major_formatter(ThetaFormatter())
|
|
397
|
+
self.isDefault_majloc = True
|
|
398
|
+
self.isDefault_majfmt = True
|
|
399
|
+
|
|
400
|
+
def clear(self):
|
|
401
|
+
# docstring inherited
|
|
402
|
+
super().clear()
|
|
403
|
+
self.set_ticks_position('none')
|
|
404
|
+
self._wrap_locator_formatter()
|
|
405
|
+
|
|
406
|
+
def _set_scale(self, value, **kwargs):
|
|
407
|
+
if value != 'linear':
|
|
408
|
+
raise NotImplementedError(
|
|
409
|
+
"The xscale cannot be set on a polar plot")
|
|
410
|
+
super()._set_scale(value, **kwargs)
|
|
411
|
+
# LinearScale.set_default_locators_and_formatters just set the major
|
|
412
|
+
# locator to be an AutoLocator, so we customize it here to have ticks
|
|
413
|
+
# at sensible degree multiples.
|
|
414
|
+
self.get_major_locator().set_params(steps=[1, 1.5, 3, 4.5, 9, 10])
|
|
415
|
+
self._wrap_locator_formatter()
|
|
416
|
+
|
|
417
|
+
def _copy_tick_props(self, src, dest):
|
|
418
|
+
"""Copy the props from src tick to dest tick."""
|
|
419
|
+
if src is None or dest is None:
|
|
420
|
+
return
|
|
421
|
+
super()._copy_tick_props(src, dest)
|
|
422
|
+
|
|
423
|
+
# Ensure that tick transforms are independent so that padding works.
|
|
424
|
+
trans = dest._get_text1_transform()[0]
|
|
425
|
+
dest.label1.set_transform(trans + dest._text1_translate)
|
|
426
|
+
trans = dest._get_text2_transform()[0]
|
|
427
|
+
dest.label2.set_transform(trans + dest._text2_translate)
|
|
428
|
+
|
|
429
|
+
|
|
430
|
+
class RadialLocator(mticker.Locator):
|
|
431
|
+
"""
|
|
432
|
+
Used to locate radius ticks.
|
|
433
|
+
|
|
434
|
+
Ensures that all ticks are strictly positive. For all other tasks, it
|
|
435
|
+
delegates to the base `.Locator` (which may be different depending on the
|
|
436
|
+
scale of the *r*-axis).
|
|
437
|
+
"""
|
|
438
|
+
|
|
439
|
+
@_api.delete_parameter("3.11", "axes")
|
|
440
|
+
def __init__(self, base, axes=None):
|
|
441
|
+
self.base = base
|
|
442
|
+
self._axes = axes
|
|
443
|
+
|
|
444
|
+
def set_axis(self, axis):
|
|
445
|
+
self.base.set_axis(axis)
|
|
446
|
+
|
|
447
|
+
def __call__(self):
|
|
448
|
+
# Ensure previous behaviour with full circle non-annular views.
|
|
449
|
+
ax = self.base.axis.axes
|
|
450
|
+
if _is_full_circle_rad(*ax.viewLim.intervalx):
|
|
451
|
+
rorigin = ax.get_rorigin() * ax.get_rsign()
|
|
452
|
+
if ax.get_rmin() <= rorigin:
|
|
453
|
+
return [tick for tick in self.base() if tick > rorigin]
|
|
454
|
+
return self.base()
|
|
455
|
+
|
|
456
|
+
def _zero_in_bounds(self):
|
|
457
|
+
"""
|
|
458
|
+
Return True if zero is within the valid values for the
|
|
459
|
+
scale of the radial axis.
|
|
460
|
+
"""
|
|
461
|
+
vmin, vmax = self.base.axis._scale.limit_range_for_scale(0, 1, 1e-5)
|
|
462
|
+
return vmin == 0
|
|
463
|
+
|
|
464
|
+
def nonsingular(self, vmin, vmax):
|
|
465
|
+
# docstring inherited
|
|
466
|
+
if self._zero_in_bounds() and (vmin, vmax) == (-np.inf, np.inf):
|
|
467
|
+
# Initial view limits
|
|
468
|
+
return (0, 1)
|
|
469
|
+
else:
|
|
470
|
+
return self.base.nonsingular(vmin, vmax)
|
|
471
|
+
|
|
472
|
+
def view_limits(self, vmin, vmax):
|
|
473
|
+
vmin, vmax = self.base.view_limits(vmin, vmax)
|
|
474
|
+
if self._zero_in_bounds() and vmax > vmin:
|
|
475
|
+
# this allows inverted r/y-lims
|
|
476
|
+
vmin = min(0, vmin)
|
|
477
|
+
return mtransforms._nonsingular(vmin, vmax)
|
|
478
|
+
|
|
479
|
+
|
|
480
|
+
class _ThetaShift(mtransforms.ScaledTranslation):
|
|
481
|
+
"""
|
|
482
|
+
Apply a padding shift based on axes theta limits.
|
|
483
|
+
|
|
484
|
+
This is used to create padding for radial ticks.
|
|
485
|
+
|
|
486
|
+
Parameters
|
|
487
|
+
----------
|
|
488
|
+
axes : `~matplotlib.axes.Axes`
|
|
489
|
+
The owning Axes; used to determine limits.
|
|
490
|
+
pad : float
|
|
491
|
+
The padding to apply, in points.
|
|
492
|
+
mode : {'min', 'max', 'rlabel'}
|
|
493
|
+
Whether to shift away from the start (``'min'``) or the end (``'max'``)
|
|
494
|
+
of the axes, or using the rlabel position (``'rlabel'``).
|
|
495
|
+
"""
|
|
496
|
+
def __init__(self, axes, pad, mode):
|
|
497
|
+
super().__init__(pad, pad, axes.get_figure(root=False).dpi_scale_trans)
|
|
498
|
+
self.set_children(axes._realViewLim)
|
|
499
|
+
self.axes = axes
|
|
500
|
+
self.mode = mode
|
|
501
|
+
self.pad = pad
|
|
502
|
+
|
|
503
|
+
__str__ = mtransforms._make_str_method("axes", "pad", "mode")
|
|
504
|
+
|
|
505
|
+
def get_matrix(self):
|
|
506
|
+
if self._invalid:
|
|
507
|
+
if self.mode == 'rlabel':
|
|
508
|
+
angle = (
|
|
509
|
+
np.deg2rad(self.axes.get_rlabel_position()
|
|
510
|
+
* self.axes.get_theta_direction())
|
|
511
|
+
+ self.axes.get_theta_offset()
|
|
512
|
+
- np.pi / 2
|
|
513
|
+
)
|
|
514
|
+
elif self.mode == 'min':
|
|
515
|
+
angle = self.axes._realViewLim.xmin - np.pi / 2
|
|
516
|
+
elif self.mode == 'max':
|
|
517
|
+
angle = self.axes._realViewLim.xmax + np.pi / 2
|
|
518
|
+
self._t = (self.pad * np.cos(angle) / 72, self.pad * np.sin(angle) / 72)
|
|
519
|
+
return super().get_matrix()
|
|
520
|
+
|
|
521
|
+
|
|
522
|
+
class RadialTick(maxis.YTick):
|
|
523
|
+
"""
|
|
524
|
+
A radial-axis tick.
|
|
525
|
+
|
|
526
|
+
This subclass of `.YTick` provides radial ticks with some small
|
|
527
|
+
modification to their re-positioning such that ticks are rotated based on
|
|
528
|
+
axes limits. This results in ticks that are correctly perpendicular to
|
|
529
|
+
the spine. Labels are also rotated to be perpendicular to the spine, when
|
|
530
|
+
'auto' rotation is enabled.
|
|
531
|
+
"""
|
|
532
|
+
|
|
533
|
+
def __init__(self, *args, **kwargs):
|
|
534
|
+
super().__init__(*args, **kwargs)
|
|
535
|
+
self.label1.set_rotation_mode('anchor')
|
|
536
|
+
self.label2.set_rotation_mode('anchor')
|
|
537
|
+
|
|
538
|
+
def _determine_anchor(self, mode, angle, start):
|
|
539
|
+
# Note: angle is the (spine angle - 90) because it's used for the tick
|
|
540
|
+
# & text setup, so all numbers below are -90 from (normed) spine angle.
|
|
541
|
+
if mode == 'auto':
|
|
542
|
+
if start:
|
|
543
|
+
if -90 <= angle <= 90:
|
|
544
|
+
return 'left', 'center'
|
|
545
|
+
else:
|
|
546
|
+
return 'right', 'center'
|
|
547
|
+
else:
|
|
548
|
+
if -90 <= angle <= 90:
|
|
549
|
+
return 'right', 'center'
|
|
550
|
+
else:
|
|
551
|
+
return 'left', 'center'
|
|
552
|
+
else:
|
|
553
|
+
if start:
|
|
554
|
+
if angle < -68.5:
|
|
555
|
+
return 'center', 'top'
|
|
556
|
+
elif angle < -23.5:
|
|
557
|
+
return 'left', 'top'
|
|
558
|
+
elif angle < 22.5:
|
|
559
|
+
return 'left', 'center'
|
|
560
|
+
elif angle < 67.5:
|
|
561
|
+
return 'left', 'bottom'
|
|
562
|
+
elif angle < 112.5:
|
|
563
|
+
return 'center', 'bottom'
|
|
564
|
+
elif angle < 157.5:
|
|
565
|
+
return 'right', 'bottom'
|
|
566
|
+
elif angle < 202.5:
|
|
567
|
+
return 'right', 'center'
|
|
568
|
+
elif angle < 247.5:
|
|
569
|
+
return 'right', 'top'
|
|
570
|
+
else:
|
|
571
|
+
return 'center', 'top'
|
|
572
|
+
else:
|
|
573
|
+
if angle < -68.5:
|
|
574
|
+
return 'center', 'bottom'
|
|
575
|
+
elif angle < -23.5:
|
|
576
|
+
return 'right', 'bottom'
|
|
577
|
+
elif angle < 22.5:
|
|
578
|
+
return 'right', 'center'
|
|
579
|
+
elif angle < 67.5:
|
|
580
|
+
return 'right', 'top'
|
|
581
|
+
elif angle < 112.5:
|
|
582
|
+
return 'center', 'top'
|
|
583
|
+
elif angle < 157.5:
|
|
584
|
+
return 'left', 'top'
|
|
585
|
+
elif angle < 202.5:
|
|
586
|
+
return 'left', 'center'
|
|
587
|
+
elif angle < 247.5:
|
|
588
|
+
return 'left', 'bottom'
|
|
589
|
+
else:
|
|
590
|
+
return 'center', 'bottom'
|
|
591
|
+
|
|
592
|
+
def update_position(self, loc):
|
|
593
|
+
super().update_position(loc)
|
|
594
|
+
axes = self.axes
|
|
595
|
+
thetamin = axes.get_thetamin()
|
|
596
|
+
thetamax = axes.get_thetamax()
|
|
597
|
+
direction = axes.get_theta_direction()
|
|
598
|
+
offset_rad = axes.get_theta_offset()
|
|
599
|
+
offset = np.rad2deg(offset_rad)
|
|
600
|
+
full = _is_full_circle_deg(thetamin, thetamax)
|
|
601
|
+
|
|
602
|
+
if full:
|
|
603
|
+
angle = (axes.get_rlabel_position() * direction +
|
|
604
|
+
offset) % 360 - 90
|
|
605
|
+
tick_angle = 0
|
|
606
|
+
else:
|
|
607
|
+
angle = (thetamin * direction + offset) % 360 - 90
|
|
608
|
+
if direction > 0:
|
|
609
|
+
tick_angle = np.deg2rad(angle)
|
|
610
|
+
else:
|
|
611
|
+
tick_angle = np.deg2rad(angle + 180)
|
|
612
|
+
text_angle = (angle + 90) % 180 - 90 # between -90 and +90.
|
|
613
|
+
mode, user_angle = self._labelrotation
|
|
614
|
+
if mode == 'auto':
|
|
615
|
+
text_angle += user_angle
|
|
616
|
+
else:
|
|
617
|
+
text_angle = user_angle
|
|
618
|
+
|
|
619
|
+
if full:
|
|
620
|
+
ha = self.label1.get_horizontalalignment()
|
|
621
|
+
va = self.label1.get_verticalalignment()
|
|
622
|
+
else:
|
|
623
|
+
ha, va = self._determine_anchor(mode, angle, direction > 0)
|
|
624
|
+
self.label1.set_horizontalalignment(ha)
|
|
625
|
+
self.label1.set_verticalalignment(va)
|
|
626
|
+
self.label1.set_rotation(text_angle)
|
|
627
|
+
|
|
628
|
+
marker = self.tick1line.get_marker()
|
|
629
|
+
if marker == mmarkers.TICKLEFT:
|
|
630
|
+
trans = mtransforms.Affine2D().rotate(tick_angle)
|
|
631
|
+
elif marker == '_':
|
|
632
|
+
trans = mtransforms.Affine2D().rotate(tick_angle + np.pi / 2)
|
|
633
|
+
elif marker == mmarkers.TICKRIGHT:
|
|
634
|
+
trans = mtransforms.Affine2D().scale(-1, 1).rotate(tick_angle)
|
|
635
|
+
else:
|
|
636
|
+
# Don't modify custom tick line markers.
|
|
637
|
+
trans = self.tick1line._marker._transform
|
|
638
|
+
self.tick1line._marker._transform = trans
|
|
639
|
+
|
|
640
|
+
if full:
|
|
641
|
+
self.label2.set_visible(False)
|
|
642
|
+
self.tick2line.set_visible(False)
|
|
643
|
+
angle = (thetamax * direction + offset) % 360 - 90
|
|
644
|
+
if direction > 0:
|
|
645
|
+
tick_angle = np.deg2rad(angle)
|
|
646
|
+
else:
|
|
647
|
+
tick_angle = np.deg2rad(angle + 180)
|
|
648
|
+
text_angle = (angle + 90) % 180 - 90 # between -90 and +90.
|
|
649
|
+
mode, user_angle = self._labelrotation
|
|
650
|
+
if mode == 'auto':
|
|
651
|
+
text_angle += user_angle
|
|
652
|
+
else:
|
|
653
|
+
text_angle = user_angle
|
|
654
|
+
|
|
655
|
+
ha, va = self._determine_anchor(mode, angle, direction < 0)
|
|
656
|
+
self.label2.set_ha(ha)
|
|
657
|
+
self.label2.set_va(va)
|
|
658
|
+
self.label2.set_rotation(text_angle)
|
|
659
|
+
|
|
660
|
+
marker = self.tick2line.get_marker()
|
|
661
|
+
if marker == mmarkers.TICKLEFT:
|
|
662
|
+
trans = mtransforms.Affine2D().rotate(tick_angle)
|
|
663
|
+
elif marker == '_':
|
|
664
|
+
trans = mtransforms.Affine2D().rotate(tick_angle + np.pi / 2)
|
|
665
|
+
elif marker == mmarkers.TICKRIGHT:
|
|
666
|
+
trans = mtransforms.Affine2D().scale(-1, 1).rotate(tick_angle)
|
|
667
|
+
else:
|
|
668
|
+
# Don't modify custom tick line markers.
|
|
669
|
+
trans = self.tick2line._marker._transform
|
|
670
|
+
self.tick2line._marker._transform = trans
|
|
671
|
+
|
|
672
|
+
|
|
673
|
+
class RadialAxis(maxis.YAxis):
|
|
674
|
+
"""
|
|
675
|
+
A radial Axis.
|
|
676
|
+
|
|
677
|
+
This overrides certain properties of a `.YAxis` to provide special-casing
|
|
678
|
+
for a radial axis.
|
|
679
|
+
"""
|
|
680
|
+
__name__ = 'radialaxis'
|
|
681
|
+
axis_name = 'radius' #: Read-only name identifying the axis.
|
|
682
|
+
_tick_class = RadialTick
|
|
683
|
+
|
|
684
|
+
def __init__(self, *args, **kwargs):
|
|
685
|
+
super().__init__(*args, **kwargs)
|
|
686
|
+
self.sticky_edges.y.append(0)
|
|
687
|
+
|
|
688
|
+
def set_major_locator(self, locator):
|
|
689
|
+
if not isinstance(locator, RadialLocator):
|
|
690
|
+
locator = RadialLocator(locator)
|
|
691
|
+
super().set_major_locator(locator)
|
|
692
|
+
|
|
693
|
+
def clear(self):
|
|
694
|
+
# docstring inherited
|
|
695
|
+
super().clear()
|
|
696
|
+
self.set_ticks_position('none')
|
|
697
|
+
|
|
698
|
+
|
|
699
|
+
def _is_full_circle_deg(thetamin, thetamax):
|
|
700
|
+
"""
|
|
701
|
+
Determine if a wedge (in degrees) spans the full circle.
|
|
702
|
+
|
|
703
|
+
The condition is derived from :class:`~matplotlib.patches.Wedge`.
|
|
704
|
+
"""
|
|
705
|
+
return abs(abs(thetamax - thetamin) - 360.0) < 1e-12
|
|
706
|
+
|
|
707
|
+
|
|
708
|
+
def _is_full_circle_rad(thetamin, thetamax):
|
|
709
|
+
"""
|
|
710
|
+
Determine if a wedge (in radians) spans the full circle.
|
|
711
|
+
|
|
712
|
+
The condition is derived from :class:`~matplotlib.patches.Wedge`.
|
|
713
|
+
"""
|
|
714
|
+
return abs(abs(thetamax - thetamin) - 2 * np.pi) < 1.74e-14
|
|
715
|
+
|
|
716
|
+
|
|
717
|
+
class _WedgeBbox(mtransforms.Bbox):
|
|
718
|
+
"""
|
|
719
|
+
Transform (theta, r) wedge Bbox into Axes bounding box.
|
|
720
|
+
|
|
721
|
+
Parameters
|
|
722
|
+
----------
|
|
723
|
+
center : (float, float)
|
|
724
|
+
Center of the wedge
|
|
725
|
+
viewLim : `~matplotlib.transforms.Bbox`
|
|
726
|
+
Bbox determining the boundaries of the wedge
|
|
727
|
+
originLim : `~matplotlib.transforms.Bbox`
|
|
728
|
+
Bbox determining the origin for the wedge, if different from *viewLim*
|
|
729
|
+
"""
|
|
730
|
+
def __init__(self, center, viewLim, originLim, **kwargs):
|
|
731
|
+
super().__init__([[0, 0], [1, 1]], **kwargs)
|
|
732
|
+
self._center = center
|
|
733
|
+
self._viewLim = viewLim
|
|
734
|
+
self._originLim = originLim
|
|
735
|
+
self.set_children(viewLim, originLim)
|
|
736
|
+
|
|
737
|
+
__str__ = mtransforms._make_str_method("_center", "_viewLim", "_originLim")
|
|
738
|
+
|
|
739
|
+
def get_points(self):
|
|
740
|
+
# docstring inherited
|
|
741
|
+
if self._invalid:
|
|
742
|
+
points = self._viewLim.get_points().copy()
|
|
743
|
+
# Scale angular limits to work with Wedge.
|
|
744
|
+
points[:, 0] *= 180 / np.pi
|
|
745
|
+
if points[0, 0] > points[1, 0]:
|
|
746
|
+
points[:, 0] = points[::-1, 0]
|
|
747
|
+
|
|
748
|
+
# Scale radial limits based on origin radius.
|
|
749
|
+
points[:, 1] -= self._originLim.y0
|
|
750
|
+
|
|
751
|
+
# Scale radial limits to match axes limits.
|
|
752
|
+
rscale = 0.5 / points[1, 1]
|
|
753
|
+
points[:, 1] *= rscale
|
|
754
|
+
width = min(points[1, 1] - points[0, 1], 0.5)
|
|
755
|
+
|
|
756
|
+
# Generate bounding box for wedge.
|
|
757
|
+
wedge = mpatches.Wedge(self._center, points[1, 1],
|
|
758
|
+
points[0, 0], points[1, 0],
|
|
759
|
+
width=width)
|
|
760
|
+
self.update_from_path(wedge.get_path())
|
|
761
|
+
|
|
762
|
+
# Ensure equal aspect ratio.
|
|
763
|
+
w, h = self._points[1] - self._points[0]
|
|
764
|
+
deltah = max(w - h, 0) / 2
|
|
765
|
+
deltaw = max(h - w, 0) / 2
|
|
766
|
+
self._points += np.array([[-deltaw, -deltah], [deltaw, deltah]])
|
|
767
|
+
|
|
768
|
+
self._invalid = 0
|
|
769
|
+
|
|
770
|
+
return self._points
|
|
771
|
+
|
|
772
|
+
|
|
773
|
+
class PolarAxes(Axes):
|
|
774
|
+
"""
|
|
775
|
+
A polar graph projection, where the input dimensions are *theta*, *r*.
|
|
776
|
+
|
|
777
|
+
Theta starts pointing east and goes anti-clockwise.
|
|
778
|
+
"""
|
|
779
|
+
name = 'polar'
|
|
780
|
+
|
|
781
|
+
def __init__(self, *args,
|
|
782
|
+
theta_offset=0, theta_direction=1, rlabel_position=22.5,
|
|
783
|
+
**kwargs):
|
|
784
|
+
# docstring inherited
|
|
785
|
+
self._default_theta_offset = theta_offset
|
|
786
|
+
self._default_theta_direction = theta_direction
|
|
787
|
+
self._default_rlabel_position = np.deg2rad(rlabel_position)
|
|
788
|
+
super().__init__(*args, **kwargs)
|
|
789
|
+
self.use_sticky_edges = True
|
|
790
|
+
self.set_aspect('equal', adjustable='box', anchor='C')
|
|
791
|
+
self.clear()
|
|
792
|
+
|
|
793
|
+
def clear(self):
|
|
794
|
+
# docstring inherited
|
|
795
|
+
super().clear()
|
|
796
|
+
|
|
797
|
+
self.title.set_y(1.05)
|
|
798
|
+
|
|
799
|
+
start = self.spines.get('start', None)
|
|
800
|
+
if start:
|
|
801
|
+
start.set_visible(False)
|
|
802
|
+
end = self.spines.get('end', None)
|
|
803
|
+
if end:
|
|
804
|
+
end.set_visible(False)
|
|
805
|
+
self.set_xlim(0.0, 2 * np.pi)
|
|
806
|
+
|
|
807
|
+
self.grid(mpl.rcParams['polaraxes.grid'])
|
|
808
|
+
inner = self.spines.get('inner', None)
|
|
809
|
+
if inner:
|
|
810
|
+
inner.set_visible(False)
|
|
811
|
+
|
|
812
|
+
self.set_rorigin(None)
|
|
813
|
+
self.set_theta_offset(self._default_theta_offset)
|
|
814
|
+
self.set_theta_direction(self._default_theta_direction)
|
|
815
|
+
|
|
816
|
+
def _init_axis(self):
|
|
817
|
+
# This is moved out of __init__ because non-separable axes don't use it
|
|
818
|
+
self.xaxis = ThetaAxis(self, clear=False)
|
|
819
|
+
self.yaxis = RadialAxis(self, clear=False)
|
|
820
|
+
self.spines['polar'].register_axis(self.yaxis)
|
|
821
|
+
inner_spine = self.spines.get('inner', None)
|
|
822
|
+
if inner_spine is not None:
|
|
823
|
+
# Subclasses may not have inner spine.
|
|
824
|
+
inner_spine.register_axis(self.yaxis)
|
|
825
|
+
|
|
826
|
+
def _set_lim_and_transforms(self):
|
|
827
|
+
# A view limit where the minimum radius can be locked if the user
|
|
828
|
+
# specifies an alternate origin.
|
|
829
|
+
self._originViewLim = mtransforms.LockableBbox(self.viewLim)
|
|
830
|
+
|
|
831
|
+
# Handle angular offset and direction.
|
|
832
|
+
self._direction = mtransforms.Affine2D() \
|
|
833
|
+
.scale(self._default_theta_direction, 1.0)
|
|
834
|
+
self._theta_offset = mtransforms.Affine2D() \
|
|
835
|
+
.translate(self._default_theta_offset, 0.0)
|
|
836
|
+
self.transShift = self._direction + self._theta_offset
|
|
837
|
+
# A view limit shifted to the correct location after accounting for
|
|
838
|
+
# orientation and offset.
|
|
839
|
+
self._realViewLim = mtransforms.TransformedBbox(self.viewLim,
|
|
840
|
+
self.transShift)
|
|
841
|
+
|
|
842
|
+
# Transforms the x and y axis separately by a scale factor
|
|
843
|
+
# It is assumed that this part will have non-linear components
|
|
844
|
+
self.transScale = mtransforms.TransformWrapper(
|
|
845
|
+
mtransforms.IdentityTransform())
|
|
846
|
+
|
|
847
|
+
# Scale view limit into a bbox around the selected wedge. This may be
|
|
848
|
+
# smaller than the usual unit axes rectangle if not plotting the full
|
|
849
|
+
# circle.
|
|
850
|
+
self.axesLim = _WedgeBbox((0.5, 0.5),
|
|
851
|
+
self._realViewLim, self._originViewLim)
|
|
852
|
+
|
|
853
|
+
# Scale the wedge to fill the axes.
|
|
854
|
+
self.transWedge = mtransforms.BboxTransformFrom(self.axesLim)
|
|
855
|
+
|
|
856
|
+
# Scale the axes to fill the figure.
|
|
857
|
+
self.transAxes = mtransforms.BboxTransformTo(self.bbox)
|
|
858
|
+
|
|
859
|
+
# A (possibly non-linear) projection on the (already scaled)
|
|
860
|
+
# data. This one is aware of rmin
|
|
861
|
+
self.transProjection = self.PolarTransform(
|
|
862
|
+
self,
|
|
863
|
+
scale_transform=self.transScale
|
|
864
|
+
)
|
|
865
|
+
# Add dependency on rorigin.
|
|
866
|
+
self.transProjection.set_children(self._originViewLim)
|
|
867
|
+
|
|
868
|
+
# An affine transformation on the data, generally to limit the
|
|
869
|
+
# range of the axes
|
|
870
|
+
self.transProjectionAffine = self.PolarAffine(self.transScale,
|
|
871
|
+
self._originViewLim)
|
|
872
|
+
|
|
873
|
+
# The complete data transformation stack -- from data all the
|
|
874
|
+
# way to display coordinates
|
|
875
|
+
#
|
|
876
|
+
# 1. Remove any radial axis scaling (e.g. log scaling)
|
|
877
|
+
# 2. Shift data in the theta direction
|
|
878
|
+
# 3. Project the data from polar to cartesian values
|
|
879
|
+
# (with the origin in the same place)
|
|
880
|
+
# 4. Scale and translate the cartesian values to Axes coordinates
|
|
881
|
+
# (here the origin is moved to the lower left of the Axes)
|
|
882
|
+
# 5. Move and scale to fill the Axes
|
|
883
|
+
# 6. Convert from Axes coordinates to Figure coordinates
|
|
884
|
+
self.transData = (
|
|
885
|
+
self.transScale +
|
|
886
|
+
self.transShift +
|
|
887
|
+
self.transProjection +
|
|
888
|
+
(
|
|
889
|
+
self.transProjectionAffine +
|
|
890
|
+
self.transWedge +
|
|
891
|
+
self.transAxes
|
|
892
|
+
)
|
|
893
|
+
)
|
|
894
|
+
|
|
895
|
+
# This is the transform for theta-axis ticks. It is
|
|
896
|
+
# equivalent to transData, except it always puts r == 0.0 and r == 1.0
|
|
897
|
+
# at the edge of the axis circles.
|
|
898
|
+
self._xaxis_transform = (
|
|
899
|
+
mtransforms.blended_transform_factory(
|
|
900
|
+
mtransforms.IdentityTransform(),
|
|
901
|
+
mtransforms.BboxTransformTo(self.viewLim)) +
|
|
902
|
+
self.transData)
|
|
903
|
+
# The theta labels are flipped along the radius, so that text 1 is on
|
|
904
|
+
# the outside by default. This should work the same as before.
|
|
905
|
+
flipr_transform = mtransforms.Affine2D() \
|
|
906
|
+
.translate(0.0, -0.5) \
|
|
907
|
+
.scale(1.0, -1.0) \
|
|
908
|
+
.translate(0.0, 0.5)
|
|
909
|
+
self._xaxis_text_transform = flipr_transform + self._xaxis_transform
|
|
910
|
+
|
|
911
|
+
# This is the transform for r-axis ticks. It scales the theta
|
|
912
|
+
# axis so the gridlines from 0.0 to 1.0, now go from thetamin to
|
|
913
|
+
# thetamax.
|
|
914
|
+
self._yaxis_transform = (
|
|
915
|
+
mtransforms.blended_transform_factory(
|
|
916
|
+
mtransforms.BboxTransformTo(self.viewLim),
|
|
917
|
+
mtransforms.IdentityTransform()) +
|
|
918
|
+
self.transData)
|
|
919
|
+
# The r-axis labels are put at an angle and padded in the r-direction
|
|
920
|
+
self._r_label_position = mtransforms.Affine2D() \
|
|
921
|
+
.translate(self._default_rlabel_position, 0.0)
|
|
922
|
+
self._yaxis_text_transform = mtransforms.TransformWrapper(
|
|
923
|
+
self._r_label_position + self.transData)
|
|
924
|
+
|
|
925
|
+
def get_xaxis_transform(self, which='grid'):
|
|
926
|
+
_api.check_in_list(['tick1', 'tick2', 'grid'], which=which)
|
|
927
|
+
return self._xaxis_transform
|
|
928
|
+
|
|
929
|
+
def get_xaxis_text1_transform(self, pad):
|
|
930
|
+
return self._xaxis_text_transform, 'center', 'center'
|
|
931
|
+
|
|
932
|
+
def get_xaxis_text2_transform(self, pad):
|
|
933
|
+
return self._xaxis_text_transform, 'center', 'center'
|
|
934
|
+
|
|
935
|
+
def get_yaxis_transform(self, which='grid'):
|
|
936
|
+
if which in ('tick1', 'tick2'):
|
|
937
|
+
return self._yaxis_text_transform
|
|
938
|
+
elif which == 'grid':
|
|
939
|
+
return self._yaxis_transform
|
|
940
|
+
else:
|
|
941
|
+
_api.check_in_list(['tick1', 'tick2', 'grid'], which=which)
|
|
942
|
+
|
|
943
|
+
def get_yaxis_text1_transform(self, pad):
|
|
944
|
+
thetamin, thetamax = self._realViewLim.intervalx
|
|
945
|
+
if _is_full_circle_rad(thetamin, thetamax):
|
|
946
|
+
return self._yaxis_text_transform, 'bottom', 'left'
|
|
947
|
+
elif self.get_theta_direction() > 0:
|
|
948
|
+
halign = 'left'
|
|
949
|
+
pad_shift = _ThetaShift(self, pad, 'min')
|
|
950
|
+
else:
|
|
951
|
+
halign = 'right'
|
|
952
|
+
pad_shift = _ThetaShift(self, pad, 'max')
|
|
953
|
+
return self._yaxis_text_transform + pad_shift, 'center', halign
|
|
954
|
+
|
|
955
|
+
def get_yaxis_text2_transform(self, pad):
|
|
956
|
+
if self.get_theta_direction() > 0:
|
|
957
|
+
halign = 'right'
|
|
958
|
+
pad_shift = _ThetaShift(self, pad, 'max')
|
|
959
|
+
else:
|
|
960
|
+
halign = 'left'
|
|
961
|
+
pad_shift = _ThetaShift(self, pad, 'min')
|
|
962
|
+
return self._yaxis_text_transform + pad_shift, 'center', halign
|
|
963
|
+
|
|
964
|
+
def draw(self, renderer):
|
|
965
|
+
self._unstale_viewLim()
|
|
966
|
+
thetamin, thetamax = np.rad2deg(self._realViewLim.intervalx)
|
|
967
|
+
if thetamin > thetamax:
|
|
968
|
+
thetamin, thetamax = thetamax, thetamin
|
|
969
|
+
rscale_tr = self.yaxis.get_transform()
|
|
970
|
+
rmin, rmax = ((rscale_tr.transform(self._realViewLim.intervaly) -
|
|
971
|
+
rscale_tr.transform(self.get_rorigin())) *
|
|
972
|
+
self.get_rsign())
|
|
973
|
+
if isinstance(self.patch, mpatches.Wedge):
|
|
974
|
+
# Backwards-compatibility: Any subclassed Axes might override the
|
|
975
|
+
# patch to not be the Wedge that PolarAxes uses.
|
|
976
|
+
center = self.transWedge.transform((0.5, 0.5))
|
|
977
|
+
self.patch.set_center(center)
|
|
978
|
+
self.patch.set_theta1(thetamin)
|
|
979
|
+
self.patch.set_theta2(thetamax)
|
|
980
|
+
|
|
981
|
+
edge, _ = self.transWedge.transform((1, 0))
|
|
982
|
+
radius = edge - center[0]
|
|
983
|
+
width = min(radius * (rmax - rmin) / rmax, radius)
|
|
984
|
+
self.patch.set_radius(radius)
|
|
985
|
+
self.patch.set_width(width)
|
|
986
|
+
|
|
987
|
+
inner_width = radius - width
|
|
988
|
+
inner = self.spines.get('inner', None)
|
|
989
|
+
if inner:
|
|
990
|
+
inner.set_visible(inner_width != 0.0)
|
|
991
|
+
|
|
992
|
+
visible = not _is_full_circle_deg(thetamin, thetamax)
|
|
993
|
+
# For backwards compatibility, any subclassed Axes might override the
|
|
994
|
+
# spines to not include start/end that PolarAxes uses.
|
|
995
|
+
start = self.spines.get('start', None)
|
|
996
|
+
end = self.spines.get('end', None)
|
|
997
|
+
if start:
|
|
998
|
+
start.set_visible(visible)
|
|
999
|
+
if end:
|
|
1000
|
+
end.set_visible(visible)
|
|
1001
|
+
if visible:
|
|
1002
|
+
yaxis_text_transform = self._yaxis_transform
|
|
1003
|
+
else:
|
|
1004
|
+
yaxis_text_transform = self._r_label_position + self.transData
|
|
1005
|
+
if self._yaxis_text_transform != yaxis_text_transform:
|
|
1006
|
+
self._yaxis_text_transform.set(yaxis_text_transform)
|
|
1007
|
+
self.yaxis.reset_ticks()
|
|
1008
|
+
self.yaxis.set_clip_path(self.patch)
|
|
1009
|
+
|
|
1010
|
+
super().draw(renderer)
|
|
1011
|
+
|
|
1012
|
+
def _gen_axes_patch(self):
|
|
1013
|
+
return mpatches.Wedge((0.5, 0.5), 0.5, 0.0, 360.0)
|
|
1014
|
+
|
|
1015
|
+
def _gen_axes_spines(self):
|
|
1016
|
+
spines = {
|
|
1017
|
+
'polar': Spine.arc_spine(self, 'top', (0.5, 0.5), 0.5, 0, 360),
|
|
1018
|
+
'start': Spine.linear_spine(self, 'left'),
|
|
1019
|
+
'end': Spine.linear_spine(self, 'right'),
|
|
1020
|
+
'inner': Spine.arc_spine(self, 'bottom', (0.5, 0.5), 0.0, 0, 360),
|
|
1021
|
+
}
|
|
1022
|
+
spines['polar'].set_transform(self.transWedge + self.transAxes)
|
|
1023
|
+
spines['inner'].set_transform(self.transWedge + self.transAxes)
|
|
1024
|
+
spines['start'].set_transform(self._yaxis_transform)
|
|
1025
|
+
spines['end'].set_transform(self._yaxis_transform)
|
|
1026
|
+
return spines
|
|
1027
|
+
|
|
1028
|
+
def set_thetamax(self, thetamax):
|
|
1029
|
+
"""Set the maximum theta limit in degrees."""
|
|
1030
|
+
self.viewLim.x1 = np.deg2rad(thetamax)
|
|
1031
|
+
|
|
1032
|
+
def get_thetamax(self):
|
|
1033
|
+
"""Return the maximum theta limit in degrees."""
|
|
1034
|
+
return np.rad2deg(self.viewLim.xmax)
|
|
1035
|
+
|
|
1036
|
+
def set_thetamin(self, thetamin):
|
|
1037
|
+
"""Set the minimum theta limit in degrees."""
|
|
1038
|
+
self.viewLim.x0 = np.deg2rad(thetamin)
|
|
1039
|
+
|
|
1040
|
+
def get_thetamin(self):
|
|
1041
|
+
"""Get the minimum theta limit in degrees."""
|
|
1042
|
+
return np.rad2deg(self.viewLim.xmin)
|
|
1043
|
+
|
|
1044
|
+
def set_thetalim(self, *args, **kwargs):
|
|
1045
|
+
r"""
|
|
1046
|
+
Set the minimum and maximum theta values.
|
|
1047
|
+
|
|
1048
|
+
Can take the following signatures:
|
|
1049
|
+
|
|
1050
|
+
- ``set_thetalim(minval, maxval)``: Set the limits in radians.
|
|
1051
|
+
- ``set_thetalim(thetamin=minval, thetamax=maxval)``: Set the limits
|
|
1052
|
+
in degrees.
|
|
1053
|
+
|
|
1054
|
+
where minval and maxval are the minimum and maximum limits. Values are
|
|
1055
|
+
wrapped in to the range :math:`[0, 2\pi]` (in radians), so for example
|
|
1056
|
+
it is possible to do ``set_thetalim(-np.pi / 2, np.pi / 2)`` to have
|
|
1057
|
+
an axis symmetric around 0. A ValueError is raised if the absolute
|
|
1058
|
+
angle difference is larger than a full circle.
|
|
1059
|
+
"""
|
|
1060
|
+
orig_lim = self.get_xlim() # in radians
|
|
1061
|
+
if 'thetamin' in kwargs:
|
|
1062
|
+
kwargs['xmin'] = np.deg2rad(kwargs.pop('thetamin'))
|
|
1063
|
+
if 'thetamax' in kwargs:
|
|
1064
|
+
kwargs['xmax'] = np.deg2rad(kwargs.pop('thetamax'))
|
|
1065
|
+
new_min, new_max = self.set_xlim(*args, **kwargs)
|
|
1066
|
+
# Parsing all permutations of *args, **kwargs is tricky; it is simpler
|
|
1067
|
+
# to let set_xlim() do it and then validate the limits.
|
|
1068
|
+
if abs(new_max - new_min) > 2 * np.pi:
|
|
1069
|
+
self.set_xlim(orig_lim) # un-accept the change
|
|
1070
|
+
raise ValueError("The angle range must be less than a full circle")
|
|
1071
|
+
return tuple(np.rad2deg((new_min, new_max)))
|
|
1072
|
+
|
|
1073
|
+
def set_theta_offset(self, offset):
|
|
1074
|
+
"""
|
|
1075
|
+
Set the offset for the location of 0 in radians.
|
|
1076
|
+
"""
|
|
1077
|
+
mtx = self._theta_offset.get_matrix()
|
|
1078
|
+
mtx[0, 2] = offset
|
|
1079
|
+
self._theta_offset.invalidate()
|
|
1080
|
+
|
|
1081
|
+
def get_theta_offset(self):
|
|
1082
|
+
"""
|
|
1083
|
+
Get the offset for the location of 0 in radians.
|
|
1084
|
+
"""
|
|
1085
|
+
return self._theta_offset.get_matrix()[0, 2]
|
|
1086
|
+
|
|
1087
|
+
def set_theta_zero_location(self, loc, offset=0.0):
|
|
1088
|
+
"""
|
|
1089
|
+
Set the location of theta's zero.
|
|
1090
|
+
|
|
1091
|
+
This simply calls `set_theta_offset` with the correct value in radians.
|
|
1092
|
+
|
|
1093
|
+
Parameters
|
|
1094
|
+
----------
|
|
1095
|
+
loc : str
|
|
1096
|
+
May be one of "N", "NW", "W", "SW", "S", "SE", "E", or "NE".
|
|
1097
|
+
offset : float, default: 0
|
|
1098
|
+
An offset in degrees to apply from the specified *loc*. **Note:**
|
|
1099
|
+
this offset is *always* applied counter-clockwise regardless of
|
|
1100
|
+
the direction setting.
|
|
1101
|
+
"""
|
|
1102
|
+
mapping = {
|
|
1103
|
+
'N': np.pi * 0.5,
|
|
1104
|
+
'NW': np.pi * 0.75,
|
|
1105
|
+
'W': np.pi,
|
|
1106
|
+
'SW': np.pi * 1.25,
|
|
1107
|
+
'S': np.pi * 1.5,
|
|
1108
|
+
'SE': np.pi * 1.75,
|
|
1109
|
+
'E': 0,
|
|
1110
|
+
'NE': np.pi * 0.25}
|
|
1111
|
+
return self.set_theta_offset(mapping[loc] + np.deg2rad(offset))
|
|
1112
|
+
|
|
1113
|
+
def set_theta_direction(self, direction):
|
|
1114
|
+
"""
|
|
1115
|
+
Set the direction in which theta increases.
|
|
1116
|
+
|
|
1117
|
+
clockwise, -1:
|
|
1118
|
+
Theta increases in the clockwise direction
|
|
1119
|
+
|
|
1120
|
+
counterclockwise, anticlockwise, 1:
|
|
1121
|
+
Theta increases in the counterclockwise direction
|
|
1122
|
+
"""
|
|
1123
|
+
mtx = self._direction.get_matrix()
|
|
1124
|
+
if direction in ('clockwise', -1):
|
|
1125
|
+
mtx[0, 0] = -1
|
|
1126
|
+
elif direction in ('counterclockwise', 'anticlockwise', 1):
|
|
1127
|
+
mtx[0, 0] = 1
|
|
1128
|
+
else:
|
|
1129
|
+
_api.check_in_list(
|
|
1130
|
+
[-1, 1, 'clockwise', 'counterclockwise', 'anticlockwise'],
|
|
1131
|
+
direction=direction)
|
|
1132
|
+
self._direction.invalidate()
|
|
1133
|
+
|
|
1134
|
+
def get_theta_direction(self):
|
|
1135
|
+
"""
|
|
1136
|
+
Get the direction in which theta increases.
|
|
1137
|
+
|
|
1138
|
+
-1:
|
|
1139
|
+
Theta increases in the clockwise direction
|
|
1140
|
+
|
|
1141
|
+
1:
|
|
1142
|
+
Theta increases in the counterclockwise direction
|
|
1143
|
+
"""
|
|
1144
|
+
return self._direction.get_matrix()[0, 0]
|
|
1145
|
+
|
|
1146
|
+
def set_rmax(self, rmax):
|
|
1147
|
+
"""
|
|
1148
|
+
Set the outer radial limit.
|
|
1149
|
+
|
|
1150
|
+
Parameters
|
|
1151
|
+
----------
|
|
1152
|
+
rmax : float
|
|
1153
|
+
"""
|
|
1154
|
+
self.viewLim.y1 = rmax
|
|
1155
|
+
|
|
1156
|
+
def get_rmax(self):
|
|
1157
|
+
"""
|
|
1158
|
+
Returns
|
|
1159
|
+
-------
|
|
1160
|
+
float
|
|
1161
|
+
Outer radial limit.
|
|
1162
|
+
"""
|
|
1163
|
+
return self.viewLim.ymax
|
|
1164
|
+
|
|
1165
|
+
def set_rmin(self, rmin):
|
|
1166
|
+
"""
|
|
1167
|
+
Set the inner radial limit.
|
|
1168
|
+
|
|
1169
|
+
Parameters
|
|
1170
|
+
----------
|
|
1171
|
+
rmin : float
|
|
1172
|
+
"""
|
|
1173
|
+
self.viewLim.y0 = rmin
|
|
1174
|
+
|
|
1175
|
+
def get_rmin(self):
|
|
1176
|
+
"""
|
|
1177
|
+
Returns
|
|
1178
|
+
-------
|
|
1179
|
+
float
|
|
1180
|
+
The inner radial limit.
|
|
1181
|
+
"""
|
|
1182
|
+
return self.viewLim.ymin
|
|
1183
|
+
|
|
1184
|
+
def set_rorigin(self, rorigin):
|
|
1185
|
+
"""
|
|
1186
|
+
Update the radial origin.
|
|
1187
|
+
|
|
1188
|
+
Parameters
|
|
1189
|
+
----------
|
|
1190
|
+
rorigin : float
|
|
1191
|
+
"""
|
|
1192
|
+
self._originViewLim.locked_y0 = rorigin
|
|
1193
|
+
|
|
1194
|
+
def get_rorigin(self):
|
|
1195
|
+
"""
|
|
1196
|
+
Returns
|
|
1197
|
+
-------
|
|
1198
|
+
float
|
|
1199
|
+
"""
|
|
1200
|
+
return self._originViewLim.y0
|
|
1201
|
+
|
|
1202
|
+
def get_rsign(self):
|
|
1203
|
+
return np.sign(self._originViewLim.y1 - self._originViewLim.y0)
|
|
1204
|
+
|
|
1205
|
+
def set_rlim(self, bottom=None, top=None, *,
|
|
1206
|
+
emit=True, auto=False, **kwargs):
|
|
1207
|
+
"""
|
|
1208
|
+
Set the radial axis view limits.
|
|
1209
|
+
|
|
1210
|
+
This function behaves like `.Axes.set_ylim`, but additionally supports
|
|
1211
|
+
*rmin* and *rmax* as aliases for *bottom* and *top*.
|
|
1212
|
+
|
|
1213
|
+
See Also
|
|
1214
|
+
--------
|
|
1215
|
+
.Axes.set_ylim
|
|
1216
|
+
"""
|
|
1217
|
+
if 'rmin' in kwargs:
|
|
1218
|
+
if bottom is None:
|
|
1219
|
+
bottom = kwargs.pop('rmin')
|
|
1220
|
+
else:
|
|
1221
|
+
raise ValueError('Cannot supply both positional "bottom"'
|
|
1222
|
+
'argument and kwarg "rmin"')
|
|
1223
|
+
if 'rmax' in kwargs:
|
|
1224
|
+
if top is None:
|
|
1225
|
+
top = kwargs.pop('rmax')
|
|
1226
|
+
else:
|
|
1227
|
+
raise ValueError('Cannot supply both positional "top"'
|
|
1228
|
+
'argument and kwarg "rmax"')
|
|
1229
|
+
return self.set_ylim(bottom=bottom, top=top, emit=emit, auto=auto,
|
|
1230
|
+
**kwargs)
|
|
1231
|
+
|
|
1232
|
+
def get_rlabel_position(self):
|
|
1233
|
+
"""
|
|
1234
|
+
Returns
|
|
1235
|
+
-------
|
|
1236
|
+
float
|
|
1237
|
+
The theta position of the radius labels in degrees.
|
|
1238
|
+
"""
|
|
1239
|
+
return np.rad2deg(self._r_label_position.get_matrix()[0, 2])
|
|
1240
|
+
|
|
1241
|
+
def set_rlabel_position(self, value):
|
|
1242
|
+
"""
|
|
1243
|
+
Update the theta position of the radius labels.
|
|
1244
|
+
|
|
1245
|
+
Parameters
|
|
1246
|
+
----------
|
|
1247
|
+
value : number
|
|
1248
|
+
The angular position of the radius labels in degrees.
|
|
1249
|
+
"""
|
|
1250
|
+
self._r_label_position.clear().translate(np.deg2rad(value), 0.0)
|
|
1251
|
+
|
|
1252
|
+
def set_rscale(self, *args, **kwargs):
|
|
1253
|
+
return Axes.set_yscale(self, *args, **kwargs)
|
|
1254
|
+
|
|
1255
|
+
def set_rticks(self, *args, **kwargs):
|
|
1256
|
+
return Axes.set_yticks(self, *args, **kwargs)
|
|
1257
|
+
|
|
1258
|
+
def set_thetagrids(self, angles, labels=None, fmt=None, **kwargs):
|
|
1259
|
+
"""
|
|
1260
|
+
Set the theta gridlines in a polar plot.
|
|
1261
|
+
|
|
1262
|
+
Parameters
|
|
1263
|
+
----------
|
|
1264
|
+
angles : tuple with floats, degrees
|
|
1265
|
+
The angles of the theta gridlines.
|
|
1266
|
+
|
|
1267
|
+
labels : tuple with strings or None
|
|
1268
|
+
The labels to use at each theta gridline. The
|
|
1269
|
+
`.projections.polar.ThetaFormatter` will be used if None.
|
|
1270
|
+
|
|
1271
|
+
fmt : str or None
|
|
1272
|
+
Format string used in `matplotlib.ticker.FormatStrFormatter`.
|
|
1273
|
+
For example '%f'. Note that the angle that is used is in
|
|
1274
|
+
radians.
|
|
1275
|
+
|
|
1276
|
+
Returns
|
|
1277
|
+
-------
|
|
1278
|
+
lines : list of `.lines.Line2D`
|
|
1279
|
+
The theta gridlines.
|
|
1280
|
+
|
|
1281
|
+
labels : list of `.text.Text`
|
|
1282
|
+
The tick labels.
|
|
1283
|
+
|
|
1284
|
+
Other Parameters
|
|
1285
|
+
----------------
|
|
1286
|
+
**kwargs
|
|
1287
|
+
*kwargs* are optional `.Text` properties for the labels.
|
|
1288
|
+
|
|
1289
|
+
.. warning::
|
|
1290
|
+
|
|
1291
|
+
This only sets the properties of the current ticks.
|
|
1292
|
+
Ticks are not guaranteed to be persistent. Various operations
|
|
1293
|
+
can create, delete and modify the Tick instances. There is an
|
|
1294
|
+
imminent risk that these settings can get lost if you work on
|
|
1295
|
+
the figure further (including also panning/zooming on a
|
|
1296
|
+
displayed figure).
|
|
1297
|
+
|
|
1298
|
+
Use `.set_tick_params` instead if possible.
|
|
1299
|
+
|
|
1300
|
+
See Also
|
|
1301
|
+
--------
|
|
1302
|
+
.PolarAxes.set_rgrids
|
|
1303
|
+
.Axis.get_gridlines
|
|
1304
|
+
.Axis.get_ticklabels
|
|
1305
|
+
"""
|
|
1306
|
+
|
|
1307
|
+
# Make sure we take into account unitized data
|
|
1308
|
+
angles = self.convert_yunits(angles)
|
|
1309
|
+
angles = np.deg2rad(angles)
|
|
1310
|
+
self.set_xticks(angles)
|
|
1311
|
+
if labels is not None:
|
|
1312
|
+
self.set_xticklabels(labels)
|
|
1313
|
+
elif fmt is not None:
|
|
1314
|
+
self.xaxis.set_major_formatter(mticker.FormatStrFormatter(fmt))
|
|
1315
|
+
for t in self.xaxis.get_ticklabels():
|
|
1316
|
+
t._internal_update(kwargs)
|
|
1317
|
+
return self.xaxis.get_ticklines(), self.xaxis.get_ticklabels()
|
|
1318
|
+
|
|
1319
|
+
def set_rgrids(self, radii, labels=None, angle=None, fmt=None, **kwargs):
|
|
1320
|
+
"""
|
|
1321
|
+
Set the radial gridlines on a polar plot.
|
|
1322
|
+
|
|
1323
|
+
Parameters
|
|
1324
|
+
----------
|
|
1325
|
+
radii : tuple with floats
|
|
1326
|
+
The radii for the radial gridlines
|
|
1327
|
+
|
|
1328
|
+
labels : tuple with strings or None
|
|
1329
|
+
The labels to use at each radial gridline. The
|
|
1330
|
+
`matplotlib.ticker.ScalarFormatter` will be used if None.
|
|
1331
|
+
|
|
1332
|
+
angle : float
|
|
1333
|
+
The angular position of the radius labels in degrees.
|
|
1334
|
+
|
|
1335
|
+
fmt : str or None
|
|
1336
|
+
Format string used in `matplotlib.ticker.FormatStrFormatter`.
|
|
1337
|
+
For example '%f'.
|
|
1338
|
+
|
|
1339
|
+
Returns
|
|
1340
|
+
-------
|
|
1341
|
+
lines : list of `.lines.Line2D`
|
|
1342
|
+
The radial gridlines.
|
|
1343
|
+
|
|
1344
|
+
labels : list of `.text.Text`
|
|
1345
|
+
The tick labels.
|
|
1346
|
+
|
|
1347
|
+
Other Parameters
|
|
1348
|
+
----------------
|
|
1349
|
+
**kwargs
|
|
1350
|
+
*kwargs* are optional `.Text` properties for the labels.
|
|
1351
|
+
|
|
1352
|
+
.. warning::
|
|
1353
|
+
|
|
1354
|
+
This only sets the properties of the current ticks.
|
|
1355
|
+
Ticks are not guaranteed to be persistent. Various operations
|
|
1356
|
+
can create, delete and modify the Tick instances. There is an
|
|
1357
|
+
imminent risk that these settings can get lost if you work on
|
|
1358
|
+
the figure further (including also panning/zooming on a
|
|
1359
|
+
displayed figure).
|
|
1360
|
+
|
|
1361
|
+
Use `.set_tick_params` instead if possible.
|
|
1362
|
+
|
|
1363
|
+
See Also
|
|
1364
|
+
--------
|
|
1365
|
+
.PolarAxes.set_thetagrids
|
|
1366
|
+
.Axis.get_gridlines
|
|
1367
|
+
.Axis.get_ticklabels
|
|
1368
|
+
"""
|
|
1369
|
+
# Make sure we take into account unitized data
|
|
1370
|
+
radii = self.convert_xunits(radii)
|
|
1371
|
+
radii = np.asarray(radii)
|
|
1372
|
+
|
|
1373
|
+
self.set_yticks(radii)
|
|
1374
|
+
if labels is not None:
|
|
1375
|
+
self.set_yticklabels(labels)
|
|
1376
|
+
elif fmt is not None:
|
|
1377
|
+
self.yaxis.set_major_formatter(mticker.FormatStrFormatter(fmt))
|
|
1378
|
+
if angle is None:
|
|
1379
|
+
angle = self.get_rlabel_position()
|
|
1380
|
+
self.set_rlabel_position(angle)
|
|
1381
|
+
for t in self.yaxis.get_ticklabels():
|
|
1382
|
+
t._internal_update(kwargs)
|
|
1383
|
+
return self.yaxis.get_gridlines(), self.yaxis.get_ticklabels()
|
|
1384
|
+
|
|
1385
|
+
def format_coord(self, theta, r):
|
|
1386
|
+
# docstring inherited
|
|
1387
|
+
screen_xy = self.transData.transform((theta, r))
|
|
1388
|
+
screen_xys = screen_xy + np.stack(
|
|
1389
|
+
np.meshgrid([-1, 0, 1], [-1, 0, 1])).reshape((2, -1)).T
|
|
1390
|
+
ts, rs = self.transData.inverted().transform(screen_xys).T
|
|
1391
|
+
delta_t = abs((ts - theta + np.pi) % (2 * np.pi) - np.pi).max()
|
|
1392
|
+
delta_t_halfturns = delta_t / np.pi
|
|
1393
|
+
delta_t_degrees = delta_t_halfturns * 180
|
|
1394
|
+
delta_r = abs(rs - r).max()
|
|
1395
|
+
if theta < 0:
|
|
1396
|
+
theta += 2 * np.pi
|
|
1397
|
+
theta_halfturns = theta / np.pi
|
|
1398
|
+
theta_degrees = theta_halfturns * 180
|
|
1399
|
+
|
|
1400
|
+
# See ScalarFormatter.format_data_short. For r, use #g-formatting
|
|
1401
|
+
# (as for linear axes), but for theta, use f-formatting as scientific
|
|
1402
|
+
# notation doesn't make sense and the trailing dot is ugly.
|
|
1403
|
+
def format_sig(value, delta, opt, fmt):
|
|
1404
|
+
# For "f", only count digits after decimal point.
|
|
1405
|
+
prec = (max(0, -math.floor(math.log10(delta))) if fmt == "f" else
|
|
1406
|
+
cbook._g_sig_digits(value, delta))
|
|
1407
|
+
return f"{value:-{opt}.{prec}{fmt}}"
|
|
1408
|
+
|
|
1409
|
+
# In case fmt_xdata was not specified, resort to default
|
|
1410
|
+
|
|
1411
|
+
if self.fmt_ydata is None:
|
|
1412
|
+
r_label = format_sig(r, delta_r, "#", "g")
|
|
1413
|
+
else:
|
|
1414
|
+
r_label = self.format_ydata(r)
|
|
1415
|
+
|
|
1416
|
+
if self.fmt_xdata is None:
|
|
1417
|
+
return ('\N{GREEK SMALL LETTER THETA}={}\N{GREEK SMALL LETTER PI} '
|
|
1418
|
+
'({}\N{DEGREE SIGN}), r={}').format(
|
|
1419
|
+
format_sig(theta_halfturns, delta_t_halfturns, "", "f"),
|
|
1420
|
+
format_sig(theta_degrees, delta_t_degrees, "", "f"),
|
|
1421
|
+
r_label
|
|
1422
|
+
)
|
|
1423
|
+
else:
|
|
1424
|
+
return '\N{GREEK SMALL LETTER THETA}={}, r={}'.format(
|
|
1425
|
+
self.format_xdata(theta),
|
|
1426
|
+
r_label
|
|
1427
|
+
)
|
|
1428
|
+
|
|
1429
|
+
def get_data_ratio(self):
|
|
1430
|
+
"""
|
|
1431
|
+
Return the aspect ratio of the data itself. For a polar plot,
|
|
1432
|
+
this should always be 1.0
|
|
1433
|
+
"""
|
|
1434
|
+
return 1.0
|
|
1435
|
+
|
|
1436
|
+
# # # Interactive panning
|
|
1437
|
+
|
|
1438
|
+
def can_zoom(self):
|
|
1439
|
+
"""
|
|
1440
|
+
Return whether this Axes supports the zoom box button functionality.
|
|
1441
|
+
|
|
1442
|
+
A polar Axes does not support zoom boxes.
|
|
1443
|
+
"""
|
|
1444
|
+
return False
|
|
1445
|
+
|
|
1446
|
+
def can_pan(self):
|
|
1447
|
+
"""
|
|
1448
|
+
Return whether this Axes supports the pan/zoom button functionality.
|
|
1449
|
+
|
|
1450
|
+
For a polar Axes, this is slightly misleading. Both panning and
|
|
1451
|
+
zooming are performed by the same button. Panning is performed
|
|
1452
|
+
in azimuth while zooming is done along the radial.
|
|
1453
|
+
"""
|
|
1454
|
+
return True
|
|
1455
|
+
|
|
1456
|
+
def start_pan(self, x, y, button):
|
|
1457
|
+
angle = np.deg2rad(self.get_rlabel_position())
|
|
1458
|
+
mode = ''
|
|
1459
|
+
if button == 1:
|
|
1460
|
+
epsilon = np.pi / 45.0
|
|
1461
|
+
t, r = self.transData.inverted().transform((x, y))
|
|
1462
|
+
if angle - epsilon <= t <= angle + epsilon:
|
|
1463
|
+
mode = 'drag_r_labels'
|
|
1464
|
+
elif button == 3:
|
|
1465
|
+
mode = 'zoom'
|
|
1466
|
+
|
|
1467
|
+
self._pan_start = types.SimpleNamespace(
|
|
1468
|
+
rmax=self.get_rmax(),
|
|
1469
|
+
trans=self.transData.frozen(),
|
|
1470
|
+
trans_inverse=self.transData.inverted().frozen(),
|
|
1471
|
+
r_label_angle=self.get_rlabel_position(),
|
|
1472
|
+
x=x,
|
|
1473
|
+
y=y,
|
|
1474
|
+
mode=mode)
|
|
1475
|
+
|
|
1476
|
+
def end_pan(self):
|
|
1477
|
+
del self._pan_start
|
|
1478
|
+
|
|
1479
|
+
def drag_pan(self, button, key, x, y):
|
|
1480
|
+
p = self._pan_start
|
|
1481
|
+
|
|
1482
|
+
if p.mode == 'drag_r_labels':
|
|
1483
|
+
(startt, startr), (t, r) = p.trans_inverse.transform(
|
|
1484
|
+
[(p.x, p.y), (x, y)])
|
|
1485
|
+
|
|
1486
|
+
# Deal with theta
|
|
1487
|
+
dt = np.rad2deg(startt - t)
|
|
1488
|
+
self.set_rlabel_position(p.r_label_angle - dt)
|
|
1489
|
+
|
|
1490
|
+
trans, vert1, horiz1 = self.get_yaxis_text1_transform(0.0)
|
|
1491
|
+
trans, vert2, horiz2 = self.get_yaxis_text2_transform(0.0)
|
|
1492
|
+
for t in self.yaxis.majorTicks + self.yaxis.minorTicks:
|
|
1493
|
+
t.label1.set_va(vert1)
|
|
1494
|
+
t.label1.set_ha(horiz1)
|
|
1495
|
+
t.label2.set_va(vert2)
|
|
1496
|
+
t.label2.set_ha(horiz2)
|
|
1497
|
+
|
|
1498
|
+
elif p.mode == 'zoom':
|
|
1499
|
+
(startt, startr), (t, r) = p.trans_inverse.transform(
|
|
1500
|
+
[(p.x, p.y), (x, y)])
|
|
1501
|
+
|
|
1502
|
+
# Deal with r
|
|
1503
|
+
scale = r / startr
|
|
1504
|
+
self.set_rmax(p.rmax / scale)
|
|
1505
|
+
|
|
1506
|
+
|
|
1507
|
+
# To keep things all self-contained, we can put aliases to the Polar classes
|
|
1508
|
+
# defined above. This isn't strictly necessary, but it makes some of the
|
|
1509
|
+
# code more readable, and provides a backwards compatible Polar API. In
|
|
1510
|
+
# particular, this is used by the :doc:`/gallery/specialty_plots/radar_chart`
|
|
1511
|
+
# example to override PolarTransform on a PolarAxes subclass, so make sure that
|
|
1512
|
+
# that example is unaffected before changing this.
|
|
1513
|
+
PolarAxes.PolarTransform = PolarTransform
|
|
1514
|
+
PolarAxes.PolarAffine = PolarAffine
|
|
1515
|
+
PolarAxes.InvertedPolarTransform = InvertedPolarTransform
|
|
1516
|
+
PolarAxes.ThetaFormatter = ThetaFormatter
|
|
1517
|
+
PolarAxes.RadialLocator = RadialLocator
|
|
1518
|
+
PolarAxes.ThetaLocator = ThetaLocator
|