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/contour.py
ADDED
|
@@ -0,0 +1,1756 @@
|
|
|
1
|
+
# Vendored from matplotlib 3.11 (see licenses/LICENSE_MATPLOTLIB), adapted for matplotlib_rs.
|
|
2
|
+
"""
|
|
3
|
+
Classes to support contour plotting and labelling for the Axes class.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from contextlib import ExitStack
|
|
7
|
+
import functools
|
|
8
|
+
import math
|
|
9
|
+
from numbers import Integral
|
|
10
|
+
|
|
11
|
+
import numpy as np
|
|
12
|
+
from numpy import ma
|
|
13
|
+
|
|
14
|
+
import matplotlib_rs as mpl
|
|
15
|
+
from matplotlib_rs import _api, _docstring
|
|
16
|
+
from matplotlib_rs.backend_bases import MouseButton
|
|
17
|
+
from matplotlib_rs.lines import Line2D
|
|
18
|
+
from matplotlib_rs.path import Path
|
|
19
|
+
from matplotlib_rs.text import Text
|
|
20
|
+
import matplotlib_rs.ticker as ticker
|
|
21
|
+
import matplotlib_rs.cm as cm
|
|
22
|
+
import matplotlib_rs.colors as mcolors
|
|
23
|
+
import matplotlib_rs.collections as mcoll
|
|
24
|
+
import matplotlib_rs.font_manager as font_manager
|
|
25
|
+
import matplotlib_rs.cbook as cbook
|
|
26
|
+
import matplotlib_rs.patches as mpatches
|
|
27
|
+
import matplotlib_rs.transforms as mtransforms
|
|
28
|
+
from . import artist
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def _contour_labeler_event_handler(cs, inline, inline_spacing, event):
|
|
32
|
+
canvas = cs.axes.get_figure(root=True).canvas
|
|
33
|
+
is_button = event.name == "button_press_event"
|
|
34
|
+
is_key = event.name == "key_press_event"
|
|
35
|
+
# Quit (even if not in infinite mode; this is consistent with
|
|
36
|
+
# MATLAB and sometimes quite useful, but will require the user to
|
|
37
|
+
# test how many points were actually returned before using data).
|
|
38
|
+
if (is_button and event.button == MouseButton.MIDDLE
|
|
39
|
+
or is_key and event.key in ["escape", "enter"]):
|
|
40
|
+
canvas.stop_event_loop()
|
|
41
|
+
# Pop last click.
|
|
42
|
+
elif (is_button and event.button == MouseButton.RIGHT
|
|
43
|
+
or is_key and event.key in ["backspace", "delete"]):
|
|
44
|
+
# Unfortunately, if one is doing inline labels, then there is currently
|
|
45
|
+
# no way to fix the broken contour - once humpty-dumpty is broken, he
|
|
46
|
+
# can't be put back together. In inline mode, this does nothing.
|
|
47
|
+
if not inline:
|
|
48
|
+
cs.pop_label()
|
|
49
|
+
canvas.draw()
|
|
50
|
+
# Add new click.
|
|
51
|
+
elif (is_button and event.button == MouseButton.LEFT
|
|
52
|
+
# On macOS/gtk, some keys return None.
|
|
53
|
+
or is_key and event.key is not None):
|
|
54
|
+
if cs.axes.contains(event)[0]:
|
|
55
|
+
cs.add_label_near(event.x, event.y, transform=False,
|
|
56
|
+
inline=inline, inline_spacing=inline_spacing)
|
|
57
|
+
canvas.draw()
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
class ContourLabeler:
|
|
61
|
+
"""Mixin to provide labelling capability to `.ContourSet`."""
|
|
62
|
+
|
|
63
|
+
def clabel(self, levels=None, *,
|
|
64
|
+
fontsize=None, inline=True, inline_spacing=5, fmt=None,
|
|
65
|
+
colors=None, use_clabeltext=False, manual=False,
|
|
66
|
+
rightside_up=True, zorder=None):
|
|
67
|
+
"""
|
|
68
|
+
Label a contour plot.
|
|
69
|
+
|
|
70
|
+
Adds labels to line contours in this `.ContourSet` (which inherits from
|
|
71
|
+
this mixin class).
|
|
72
|
+
|
|
73
|
+
Parameters
|
|
74
|
+
----------
|
|
75
|
+
levels : array-like, optional
|
|
76
|
+
A list of level values, that should be labeled. The list must be
|
|
77
|
+
a subset of ``cs.levels``. If not given, all levels are labeled.
|
|
78
|
+
|
|
79
|
+
fontsize : str or float, default: :rc:`font.size`
|
|
80
|
+
Size in points or relative size e.g., 'small', 'x-large'.
|
|
81
|
+
See `.Text.set_size` for accepted string values.
|
|
82
|
+
|
|
83
|
+
colors : :mpltype:`color` or colors or None, default: None
|
|
84
|
+
The label colors:
|
|
85
|
+
|
|
86
|
+
- If *None*, the color of each label matches the color of
|
|
87
|
+
the corresponding contour.
|
|
88
|
+
|
|
89
|
+
- If one string color, e.g., *colors* = 'r' or *colors* =
|
|
90
|
+
'red', all labels will be plotted in this color.
|
|
91
|
+
|
|
92
|
+
- If a tuple of colors (string, float, RGB, etc), different labels
|
|
93
|
+
will be plotted in different colors in the order specified.
|
|
94
|
+
|
|
95
|
+
inline : bool, default: True
|
|
96
|
+
If ``True`` the underlying contour is removed where the label is
|
|
97
|
+
placed.
|
|
98
|
+
|
|
99
|
+
inline_spacing : float, default: 5
|
|
100
|
+
Space in pixels to leave on each side of label when placing inline.
|
|
101
|
+
|
|
102
|
+
This spacing will be exact for labels at locations where the
|
|
103
|
+
contour is straight, less so for labels on curved contours.
|
|
104
|
+
|
|
105
|
+
fmt : `.Formatter` or str or callable or dict, optional
|
|
106
|
+
How the levels are formatted:
|
|
107
|
+
|
|
108
|
+
- If a `.Formatter`, it is used to format all levels at once, using
|
|
109
|
+
its `.Formatter.format_ticks` method.
|
|
110
|
+
- If a str, it is interpreted as a %-style format string.
|
|
111
|
+
- If a callable, it is called with one level at a time and should
|
|
112
|
+
return the corresponding label.
|
|
113
|
+
- If a dict, it should directly map levels to labels.
|
|
114
|
+
|
|
115
|
+
The default is to use a standard `.ScalarFormatter`.
|
|
116
|
+
|
|
117
|
+
manual : bool or iterable, default: False
|
|
118
|
+
If ``True``, contour labels will be placed manually using
|
|
119
|
+
mouse clicks. Click the first button near a contour to
|
|
120
|
+
add a label, click the second button (or potentially both
|
|
121
|
+
mouse buttons at once) to finish adding labels. The third
|
|
122
|
+
button can be used to remove the last label added, but
|
|
123
|
+
only if labels are not inline. Alternatively, the keyboard
|
|
124
|
+
can be used to select label locations (enter to end label
|
|
125
|
+
placement, delete or backspace act like the third mouse button,
|
|
126
|
+
and any other key will select a label location).
|
|
127
|
+
|
|
128
|
+
*manual* can also be an iterable object of (x, y) tuples.
|
|
129
|
+
Contour labels will be created as if mouse is clicked at each
|
|
130
|
+
(x, y) position.
|
|
131
|
+
|
|
132
|
+
rightside_up : bool, default: True
|
|
133
|
+
If ``True``, label rotations will always be plus
|
|
134
|
+
or minus 90 degrees from level.
|
|
135
|
+
|
|
136
|
+
use_clabeltext : bool, default: False
|
|
137
|
+
If ``True``, use `.Text.set_transform_rotates_text` to ensure that
|
|
138
|
+
label rotation is updated whenever the Axes aspect changes.
|
|
139
|
+
|
|
140
|
+
zorder : float or None, default: ``(2 + contour.get_zorder())``
|
|
141
|
+
zorder of the contour labels.
|
|
142
|
+
|
|
143
|
+
Returns
|
|
144
|
+
-------
|
|
145
|
+
labels
|
|
146
|
+
A list of `.Text` instances for the labels.
|
|
147
|
+
|
|
148
|
+
Note: The returned Text instances should not be individually
|
|
149
|
+
removed or have their geometry modified, e.g. by changing text or font size.
|
|
150
|
+
If you need such a modification, remove the entire
|
|
151
|
+
`.ContourSet` and recreate it.
|
|
152
|
+
"""
|
|
153
|
+
|
|
154
|
+
if self.filled:
|
|
155
|
+
_api.warn_deprecated(
|
|
156
|
+
"3.11",
|
|
157
|
+
message="clabel() is not designed to be used with filled contours and "
|
|
158
|
+
"may result in inconsistent plots. Applying clabel() to filled "
|
|
159
|
+
"contours is thus deprecated since %(since)s. If you need "
|
|
160
|
+
"labels with filled contours, instead draw contour lines "
|
|
161
|
+
"using contour() in addition to contourf() and add the labels "
|
|
162
|
+
"to the contour lines."
|
|
163
|
+
)
|
|
164
|
+
|
|
165
|
+
# Based on the input arguments, clabel() adds a list of "label
|
|
166
|
+
# specific" attributes to the ContourSet object. These attributes are
|
|
167
|
+
# all of the form label* and names should be fairly self explanatory.
|
|
168
|
+
#
|
|
169
|
+
# Once these attributes are set, clabel passes control to the labels()
|
|
170
|
+
# method (for automatic label placement) or blocking_input_loop and
|
|
171
|
+
# _contour_labeler_event_handler (for manual label placement).
|
|
172
|
+
|
|
173
|
+
if fmt is None:
|
|
174
|
+
fmt = ticker.ScalarFormatter(useOffset=False)
|
|
175
|
+
fmt.create_dummy_axis()
|
|
176
|
+
self.labelFmt = fmt
|
|
177
|
+
self._use_clabeltext = use_clabeltext
|
|
178
|
+
self.labelManual = manual
|
|
179
|
+
self.rightside_up = rightside_up
|
|
180
|
+
self._clabel_zorder = 2 + self.get_zorder() if zorder is None else zorder
|
|
181
|
+
|
|
182
|
+
if levels is None:
|
|
183
|
+
levels = self.levels
|
|
184
|
+
indices = list(range(len(self.cvalues)))
|
|
185
|
+
else:
|
|
186
|
+
levlabs = list(levels)
|
|
187
|
+
indices, levels = [], []
|
|
188
|
+
for i, lev in enumerate(self.levels):
|
|
189
|
+
if lev in levlabs:
|
|
190
|
+
indices.append(i)
|
|
191
|
+
levels.append(lev)
|
|
192
|
+
if len(levels) < len(levlabs):
|
|
193
|
+
raise ValueError(f"Specified levels {levlabs} don't match "
|
|
194
|
+
f"available levels {self.levels}")
|
|
195
|
+
self.labelLevelList = levels
|
|
196
|
+
self.labelIndiceList = indices
|
|
197
|
+
|
|
198
|
+
self._label_font_props = font_manager.FontProperties(size=fontsize)
|
|
199
|
+
|
|
200
|
+
if colors is None:
|
|
201
|
+
self.labelMappable = self
|
|
202
|
+
self.labelCValueList = np.take(self.cvalues, self.labelIndiceList)
|
|
203
|
+
else:
|
|
204
|
+
# handling of explicit colors for labels:
|
|
205
|
+
# make labelCValueList contain integers [0, 1, 2, ...] and a cmap
|
|
206
|
+
# so that cmap(i) == colors[i]
|
|
207
|
+
num_levels = len(self.labelLevelList)
|
|
208
|
+
colors = cbook._resize_sequence(mcolors.to_rgba_array(colors), num_levels)
|
|
209
|
+
self.labelMappable = cm.ScalarMappable(
|
|
210
|
+
cmap=mcolors.ListedColormap(colors), norm=mcolors.NoNorm())
|
|
211
|
+
self.labelCValueList = list(range(num_levels))
|
|
212
|
+
|
|
213
|
+
self.labelXYs = []
|
|
214
|
+
|
|
215
|
+
if np.iterable(manual):
|
|
216
|
+
for x, y in manual:
|
|
217
|
+
self.add_label_near(x, y, inline, inline_spacing)
|
|
218
|
+
elif manual:
|
|
219
|
+
print('Select label locations manually using first mouse button.')
|
|
220
|
+
print('End manual selection with second mouse button.')
|
|
221
|
+
if not inline:
|
|
222
|
+
print('Remove last label by clicking third mouse button.')
|
|
223
|
+
mpl._blocking_input.blocking_input_loop(
|
|
224
|
+
self.axes.get_figure(root=True),
|
|
225
|
+
["button_press_event", "key_press_event"],
|
|
226
|
+
timeout=-1, handler=functools.partial(
|
|
227
|
+
_contour_labeler_event_handler,
|
|
228
|
+
self, inline, inline_spacing))
|
|
229
|
+
else:
|
|
230
|
+
self.labels(inline, inline_spacing)
|
|
231
|
+
|
|
232
|
+
return cbook.silent_list('text.Text', self.labelTexts)
|
|
233
|
+
|
|
234
|
+
def print_label(self, linecontour, labelwidth):
|
|
235
|
+
"""Return whether a contour is long enough to hold a label."""
|
|
236
|
+
return (len(linecontour) > 10 * labelwidth
|
|
237
|
+
or (len(linecontour)
|
|
238
|
+
and (np.ptp(linecontour, axis=0) > 1.2 * labelwidth).any()))
|
|
239
|
+
|
|
240
|
+
def too_close(self, x, y, lw):
|
|
241
|
+
"""Return whether a label is already near this location."""
|
|
242
|
+
thresh = (1.2 * lw) ** 2
|
|
243
|
+
return any((x - loc[0]) ** 2 + (y - loc[1]) ** 2 < thresh
|
|
244
|
+
for loc in self.labelXYs)
|
|
245
|
+
|
|
246
|
+
def _get_nth_label_width(self, nth):
|
|
247
|
+
"""Return the width of the *nth* label, in pixels."""
|
|
248
|
+
fig = self.axes.get_figure(root=False)
|
|
249
|
+
renderer = fig.get_figure(root=True)._get_renderer()
|
|
250
|
+
return (Text(0, 0,
|
|
251
|
+
self.get_text(self.labelLevelList[nth], self.labelFmt),
|
|
252
|
+
figure=fig, fontproperties=self._label_font_props)
|
|
253
|
+
.get_window_extent(renderer).width)
|
|
254
|
+
|
|
255
|
+
def get_text(self, lev, fmt):
|
|
256
|
+
"""Get the text of the label."""
|
|
257
|
+
if isinstance(lev, str):
|
|
258
|
+
return lev
|
|
259
|
+
elif isinstance(fmt, dict):
|
|
260
|
+
return fmt.get(lev, '%1.3f')
|
|
261
|
+
elif callable(getattr(fmt, "format_ticks", None)):
|
|
262
|
+
return fmt.format_ticks([*self.labelLevelList, lev])[-1]
|
|
263
|
+
elif callable(fmt):
|
|
264
|
+
return fmt(lev)
|
|
265
|
+
else:
|
|
266
|
+
return fmt % lev
|
|
267
|
+
|
|
268
|
+
def locate_label(self, linecontour, labelwidth):
|
|
269
|
+
"""
|
|
270
|
+
Find good place to draw a label (relatively flat part of the contour).
|
|
271
|
+
"""
|
|
272
|
+
ctr_size = len(linecontour)
|
|
273
|
+
n_blocks = int(np.ceil(ctr_size / labelwidth)) if labelwidth > 1 else 1
|
|
274
|
+
block_size = ctr_size if n_blocks == 1 else int(labelwidth)
|
|
275
|
+
# Split contour into blocks of length ``block_size``, filling the last
|
|
276
|
+
# block by cycling the contour start (per `np.resize` semantics). (Due
|
|
277
|
+
# to cycling, the index returned is taken modulo ctr_size.)
|
|
278
|
+
xx = np.resize(linecontour[:, 0], (n_blocks, block_size))
|
|
279
|
+
yy = np.resize(linecontour[:, 1], (n_blocks, block_size))
|
|
280
|
+
yfirst = yy[:, :1]
|
|
281
|
+
ylast = yy[:, -1:]
|
|
282
|
+
xfirst = xx[:, :1]
|
|
283
|
+
xlast = xx[:, -1:]
|
|
284
|
+
s = (yfirst - yy) * (xlast - xfirst) - (xfirst - xx) * (ylast - yfirst)
|
|
285
|
+
l = np.hypot(xlast - xfirst, ylast - yfirst)
|
|
286
|
+
# Ignore warning that divide by zero throws, as this is a valid option
|
|
287
|
+
with np.errstate(divide='ignore', invalid='ignore'):
|
|
288
|
+
distances = (abs(s) / l).sum(axis=-1)
|
|
289
|
+
# Labels are drawn in the middle of the block (``hbsize``) where the
|
|
290
|
+
# contour is the closest (per ``distances``) to a straight line, but
|
|
291
|
+
# not `too_close()` to a preexisting label.
|
|
292
|
+
hbsize = block_size // 2
|
|
293
|
+
adist = np.argsort(distances)
|
|
294
|
+
# If all candidates are `too_close()`, go back to the straightest part
|
|
295
|
+
# (``adist[0]``).
|
|
296
|
+
for idx in np.append(adist, adist[0]):
|
|
297
|
+
x, y = xx[idx, hbsize], yy[idx, hbsize]
|
|
298
|
+
if not self.too_close(x, y, labelwidth):
|
|
299
|
+
break
|
|
300
|
+
return x, y, (idx * block_size + hbsize) % ctr_size
|
|
301
|
+
|
|
302
|
+
def _split_path_and_get_label_rotation(self, path, idx, screen_pos, lw, spacing=5):
|
|
303
|
+
"""
|
|
304
|
+
Prepare for insertion of a label at index *idx* of *path*.
|
|
305
|
+
|
|
306
|
+
Parameters
|
|
307
|
+
----------
|
|
308
|
+
path : Path
|
|
309
|
+
The path where the label will be inserted, in data space.
|
|
310
|
+
idx : int
|
|
311
|
+
The vertex index after which the label will be inserted.
|
|
312
|
+
screen_pos : (float, float)
|
|
313
|
+
The position where the label will be inserted, in screen space.
|
|
314
|
+
lw : float
|
|
315
|
+
The label width, in screen space.
|
|
316
|
+
spacing : float
|
|
317
|
+
Extra spacing around the label, in screen space.
|
|
318
|
+
|
|
319
|
+
Returns
|
|
320
|
+
-------
|
|
321
|
+
path : Path
|
|
322
|
+
The path, broken so that the label can be drawn over it.
|
|
323
|
+
angle : float
|
|
324
|
+
The rotation of the label.
|
|
325
|
+
|
|
326
|
+
Notes
|
|
327
|
+
-----
|
|
328
|
+
Both tasks are done together to avoid calculating path lengths multiple times,
|
|
329
|
+
which is relatively costly.
|
|
330
|
+
|
|
331
|
+
The method used here involves computing the path length along the contour in
|
|
332
|
+
pixel coordinates and then looking (label width / 2) away from central point to
|
|
333
|
+
determine rotation and then to break contour if desired. The extra spacing is
|
|
334
|
+
taken into account when breaking the path, but not when computing the angle.
|
|
335
|
+
"""
|
|
336
|
+
xys = path.vertices
|
|
337
|
+
codes = path.codes
|
|
338
|
+
|
|
339
|
+
# Insert a vertex at idx/pos (converting back to data space), if there isn't yet
|
|
340
|
+
# a vertex there. With infinite precision one could also always insert the
|
|
341
|
+
# extra vertex (it will get masked out by the label below anyways), but floating
|
|
342
|
+
# point inaccuracies (the point can have undergone a data->screen->data
|
|
343
|
+
# transform loop) can slightly shift the point and e.g. shift the angle computed
|
|
344
|
+
# below from exactly zero to nonzero.
|
|
345
|
+
pos = self.get_transform().inverted().transform(screen_pos)
|
|
346
|
+
if not np.allclose(pos, xys[idx]):
|
|
347
|
+
xys = np.insert(xys, idx, pos, axis=0)
|
|
348
|
+
codes = np.insert(codes, idx, Path.LINETO)
|
|
349
|
+
|
|
350
|
+
# Find the connected component where the label will be inserted. Note that a
|
|
351
|
+
# path always starts with a MOVETO, and we consider there's an implicit
|
|
352
|
+
# MOVETO (closing the last path) at the end.
|
|
353
|
+
movetos = (codes == Path.MOVETO).nonzero()[0]
|
|
354
|
+
start = movetos[movetos <= idx][-1]
|
|
355
|
+
try:
|
|
356
|
+
stop = movetos[movetos > idx][0]
|
|
357
|
+
except IndexError:
|
|
358
|
+
stop = len(codes)
|
|
359
|
+
|
|
360
|
+
# Restrict ourselves to the connected component.
|
|
361
|
+
cc_xys = xys[start:stop]
|
|
362
|
+
idx -= start
|
|
363
|
+
|
|
364
|
+
# If the path is closed, rotate it s.t. it starts at the label.
|
|
365
|
+
is_closed_path = codes[stop - 1] == Path.CLOSEPOLY
|
|
366
|
+
if is_closed_path:
|
|
367
|
+
cc_xys = np.concatenate([cc_xys[idx:-1], cc_xys[:idx+1]])
|
|
368
|
+
idx = 0
|
|
369
|
+
|
|
370
|
+
# Like np.interp, but additionally vectorized over fp.
|
|
371
|
+
def interp_vec(x, xp, fp): return [np.interp(x, xp, col) for col in fp.T]
|
|
372
|
+
|
|
373
|
+
# Use cumulative path lengths ("cpl") as curvilinear coordinate along contour.
|
|
374
|
+
screen_xys = self.get_transform().transform(cc_xys)
|
|
375
|
+
path_cpls = np.insert(
|
|
376
|
+
np.cumsum(np.hypot(*np.diff(screen_xys, axis=0).T)), 0, 0)
|
|
377
|
+
path_cpls -= path_cpls[idx]
|
|
378
|
+
|
|
379
|
+
# Use linear interpolation to get end coordinates of label.
|
|
380
|
+
target_cpls = np.array([-lw/2, lw/2])
|
|
381
|
+
if is_closed_path: # For closed paths, target from the other end.
|
|
382
|
+
target_cpls[0] += (path_cpls[-1] - path_cpls[0])
|
|
383
|
+
(sx0, sx1), (sy0, sy1) = interp_vec(target_cpls, path_cpls, screen_xys)
|
|
384
|
+
angle = np.rad2deg(np.arctan2(sy1 - sy0, sx1 - sx0)) # Screen space.
|
|
385
|
+
if self.rightside_up: # Fix angle so text is never upside-down
|
|
386
|
+
angle = (angle + 90) % 180 - 90
|
|
387
|
+
|
|
388
|
+
target_cpls += [-spacing, +spacing] # Expand range by spacing.
|
|
389
|
+
|
|
390
|
+
# Get indices near points of interest; use -1 as out of bounds marker.
|
|
391
|
+
i0, i1 = np.interp(target_cpls, path_cpls, range(len(path_cpls)),
|
|
392
|
+
left=-1, right=-1)
|
|
393
|
+
i0 = math.floor(i0)
|
|
394
|
+
i1 = math.ceil(i1)
|
|
395
|
+
(x0, x1), (y0, y1) = interp_vec(target_cpls, path_cpls, cc_xys)
|
|
396
|
+
|
|
397
|
+
# Actually break contours (dropping zero-len parts).
|
|
398
|
+
new_xy_blocks = []
|
|
399
|
+
new_code_blocks = []
|
|
400
|
+
if is_closed_path:
|
|
401
|
+
if i0 != -1 and i1 != -1:
|
|
402
|
+
# This is probably wrong in the case that the entire contour would
|
|
403
|
+
# be discarded, but ensures that a valid path is returned and is
|
|
404
|
+
# consistent with behavior of mpl <3.8
|
|
405
|
+
points = cc_xys[i1:i0+1]
|
|
406
|
+
new_xy_blocks.extend([[(x1, y1)], points, [(x0, y0)]])
|
|
407
|
+
nlines = len(points) + 1
|
|
408
|
+
new_code_blocks.extend([[Path.MOVETO], [Path.LINETO] * nlines])
|
|
409
|
+
else:
|
|
410
|
+
if i0 != -1:
|
|
411
|
+
new_xy_blocks.extend([cc_xys[:i0 + 1], [(x0, y0)]])
|
|
412
|
+
new_code_blocks.extend([[Path.MOVETO], [Path.LINETO] * (i0 + 1)])
|
|
413
|
+
if i1 != -1:
|
|
414
|
+
new_xy_blocks.extend([[(x1, y1)], cc_xys[i1:]])
|
|
415
|
+
new_code_blocks.extend([
|
|
416
|
+
[Path.MOVETO], [Path.LINETO] * (len(cc_xys) - i1)])
|
|
417
|
+
|
|
418
|
+
# Back to the full path.
|
|
419
|
+
xys = np.concatenate([xys[:start], *new_xy_blocks, xys[stop:]])
|
|
420
|
+
codes = np.concatenate([codes[:start], *new_code_blocks, codes[stop:]])
|
|
421
|
+
|
|
422
|
+
return angle, Path(xys, codes)
|
|
423
|
+
|
|
424
|
+
def add_label(self, x, y, rotation, lev, cvalue):
|
|
425
|
+
"""Add a contour label, respecting whether *use_clabeltext* was set."""
|
|
426
|
+
data_x, data_y = self.axes.transData.inverted().transform((x, y))
|
|
427
|
+
t = Text(
|
|
428
|
+
data_x, data_y,
|
|
429
|
+
text=self.get_text(lev, self.labelFmt),
|
|
430
|
+
rotation=rotation,
|
|
431
|
+
horizontalalignment='center', verticalalignment='center',
|
|
432
|
+
zorder=self._clabel_zorder,
|
|
433
|
+
color=self.labelMappable.to_rgba(cvalue, alpha=self.get_alpha()),
|
|
434
|
+
fontproperties=self._label_font_props,
|
|
435
|
+
clip_box=self.axes.bbox)
|
|
436
|
+
if self._use_clabeltext:
|
|
437
|
+
data_rotation, = self.axes.transData.inverted().transform_angles(
|
|
438
|
+
[rotation], [[x, y]])
|
|
439
|
+
t.set(rotation=data_rotation, transform_rotates_text=True)
|
|
440
|
+
self.labelTexts.append(t)
|
|
441
|
+
self.labelCValues.append(cvalue)
|
|
442
|
+
self.labelXYs.append((x, y))
|
|
443
|
+
# Add label to plot here - useful for manual mode label selection
|
|
444
|
+
self.axes.add_artist(t)
|
|
445
|
+
|
|
446
|
+
def add_label_near(self, x, y, inline=True, inline_spacing=5,
|
|
447
|
+
transform=None):
|
|
448
|
+
"""
|
|
449
|
+
Add a label near the point ``(x, y)``.
|
|
450
|
+
|
|
451
|
+
Parameters
|
|
452
|
+
----------
|
|
453
|
+
x, y : float
|
|
454
|
+
The approximate location of the label.
|
|
455
|
+
inline : bool, default: True
|
|
456
|
+
If *True* remove the segment of the contour beneath the label.
|
|
457
|
+
inline_spacing : int, default: 5
|
|
458
|
+
Space in pixels to leave on each side of label when placing
|
|
459
|
+
inline. This spacing will be exact for labels at locations where
|
|
460
|
+
the contour is straight, less so for labels on curved contours.
|
|
461
|
+
transform : `.Transform` or `False`, default: ``self.axes.transData``
|
|
462
|
+
A transform applied to ``(x, y)`` before labeling. The default
|
|
463
|
+
causes ``(x, y)`` to be interpreted as data coordinates. `False`
|
|
464
|
+
is a synonym for `.IdentityTransform`; i.e. ``(x, y)`` should be
|
|
465
|
+
interpreted as display coordinates.
|
|
466
|
+
"""
|
|
467
|
+
|
|
468
|
+
if transform is None:
|
|
469
|
+
transform = self.axes.transData
|
|
470
|
+
if transform:
|
|
471
|
+
x = self.axes.convert_xunits(x)
|
|
472
|
+
y = self.axes.convert_yunits(y)
|
|
473
|
+
x, y = transform.transform((x, y))
|
|
474
|
+
|
|
475
|
+
idx_level_min, idx_vtx_min, proj = self._find_nearest_contour(
|
|
476
|
+
(x, y), self.labelIndiceList)
|
|
477
|
+
path = self._paths[idx_level_min]
|
|
478
|
+
level = self.labelIndiceList.index(idx_level_min)
|
|
479
|
+
label_width = self._get_nth_label_width(level)
|
|
480
|
+
rotation, path = self._split_path_and_get_label_rotation(
|
|
481
|
+
path, idx_vtx_min, proj, label_width, inline_spacing)
|
|
482
|
+
self.add_label(*proj, rotation, self.labelLevelList[level],
|
|
483
|
+
self.labelCValueList[level])
|
|
484
|
+
|
|
485
|
+
if inline:
|
|
486
|
+
self._paths[idx_level_min] = path
|
|
487
|
+
|
|
488
|
+
def pop_label(self, index=-1):
|
|
489
|
+
"""Defaults to removing last label, but any index can be supplied"""
|
|
490
|
+
self.labelCValues.pop(index)
|
|
491
|
+
t = self.labelTexts.pop(index)
|
|
492
|
+
t.remove()
|
|
493
|
+
|
|
494
|
+
def labels(self, inline, inline_spacing):
|
|
495
|
+
for idx, (icon, lev, cvalue) in enumerate(zip(
|
|
496
|
+
self.labelIndiceList,
|
|
497
|
+
self.labelLevelList,
|
|
498
|
+
self.labelCValueList,
|
|
499
|
+
)):
|
|
500
|
+
trans = self.get_transform()
|
|
501
|
+
label_width = self._get_nth_label_width(idx)
|
|
502
|
+
additions = []
|
|
503
|
+
for subpath in self._paths[icon]._iter_connected_components():
|
|
504
|
+
screen_xys = trans.transform(subpath.vertices)
|
|
505
|
+
# Check if long enough for a label
|
|
506
|
+
if self.print_label(screen_xys, label_width):
|
|
507
|
+
x, y, idx = self.locate_label(screen_xys, label_width)
|
|
508
|
+
rotation, path = self._split_path_and_get_label_rotation(
|
|
509
|
+
subpath, idx, (x, y),
|
|
510
|
+
label_width, inline_spacing)
|
|
511
|
+
self.add_label(x, y, rotation, lev, cvalue) # Really add label.
|
|
512
|
+
if inline: # If inline, add new contours
|
|
513
|
+
additions.append(path)
|
|
514
|
+
else: # If not adding label, keep old path
|
|
515
|
+
additions.append(subpath)
|
|
516
|
+
# After looping over all segments on a contour, replace old path by new one
|
|
517
|
+
# if inlining.
|
|
518
|
+
if inline:
|
|
519
|
+
self._paths[icon] = Path.make_compound_path(*additions)
|
|
520
|
+
|
|
521
|
+
def remove(self):
|
|
522
|
+
super().remove()
|
|
523
|
+
for text in self.labelTexts:
|
|
524
|
+
try:
|
|
525
|
+
text.remove()
|
|
526
|
+
except ValueError:
|
|
527
|
+
_api.warn_external(
|
|
528
|
+
"Some labels were manually removed from the ContourSet. "
|
|
529
|
+
"To remove labels cleanly, remove the entire ContourSet "
|
|
530
|
+
"and recreate it.")
|
|
531
|
+
self.labelTexts.clear()
|
|
532
|
+
|
|
533
|
+
|
|
534
|
+
def _find_closest_point_on_path(xys, p):
|
|
535
|
+
"""
|
|
536
|
+
Parameters
|
|
537
|
+
----------
|
|
538
|
+
xys : (N, 2) array-like
|
|
539
|
+
Coordinates of vertices.
|
|
540
|
+
p : (float, float)
|
|
541
|
+
Coordinates of point.
|
|
542
|
+
|
|
543
|
+
Returns
|
|
544
|
+
-------
|
|
545
|
+
d2min : float
|
|
546
|
+
Minimum square distance of *p* to *xys*.
|
|
547
|
+
proj : (float, float)
|
|
548
|
+
Projection of *p* onto *xys*.
|
|
549
|
+
imin : (int, int)
|
|
550
|
+
Consecutive indices of vertices of segment in *xys* where *proj* is.
|
|
551
|
+
Segments are considered as including their end-points; i.e. if the
|
|
552
|
+
closest point on the path is a node in *xys* with index *i*, this
|
|
553
|
+
returns ``(i-1, i)``. For the special case where *xys* is a single
|
|
554
|
+
point, this returns ``(0, 0)``.
|
|
555
|
+
"""
|
|
556
|
+
if len(xys) == 1:
|
|
557
|
+
return (((p - xys[0]) ** 2).sum(), xys[0], (0, 0))
|
|
558
|
+
dxys = xys[1:] - xys[:-1] # Individual segment vectors.
|
|
559
|
+
norms = (dxys ** 2).sum(axis=1)
|
|
560
|
+
norms[norms == 0] = 1 # For zero-length segment, replace 0/0 by 0/1.
|
|
561
|
+
rel_projs = np.clip( # Project onto each segment in relative 0-1 coords.
|
|
562
|
+
((p - xys[:-1]) * dxys).sum(axis=1) / norms,
|
|
563
|
+
0, 1)[:, None]
|
|
564
|
+
projs = xys[:-1] + rel_projs * dxys # Projs. onto each segment, in (x, y).
|
|
565
|
+
d2s = ((projs - p) ** 2).sum(axis=1) # Squared distances.
|
|
566
|
+
imin = np.argmin(d2s)
|
|
567
|
+
return (d2s[imin], projs[imin], (imin, imin+1))
|
|
568
|
+
|
|
569
|
+
|
|
570
|
+
_docstring.interpd.register(contour_set_attributes=r"""
|
|
571
|
+
Attributes
|
|
572
|
+
----------
|
|
573
|
+
levels : array
|
|
574
|
+
The values of the contour levels.
|
|
575
|
+
|
|
576
|
+
layers : array
|
|
577
|
+
Same as levels for line contours; half-way between
|
|
578
|
+
levels for filled contours. See ``ContourSet._process_colors``.
|
|
579
|
+
""")
|
|
580
|
+
|
|
581
|
+
|
|
582
|
+
@_docstring.interpd
|
|
583
|
+
class ContourSet(ContourLabeler, mcoll.Collection):
|
|
584
|
+
"""
|
|
585
|
+
Store a set of contour lines or filled regions.
|
|
586
|
+
|
|
587
|
+
User-callable method: `~.Axes.clabel`
|
|
588
|
+
|
|
589
|
+
Parameters
|
|
590
|
+
----------
|
|
591
|
+
ax : `~matplotlib.axes.Axes`
|
|
592
|
+
|
|
593
|
+
levels : [level0, level1, ..., leveln]
|
|
594
|
+
A list of floating point numbers indicating the contour levels.
|
|
595
|
+
|
|
596
|
+
allsegs : [level0segs, level1segs, ...]
|
|
597
|
+
List of all the polygon segments for all the *levels*.
|
|
598
|
+
For contour lines ``len(allsegs) == len(levels)``, and for
|
|
599
|
+
filled contour regions ``len(allsegs) = len(levels)-1``. The lists
|
|
600
|
+
should look like ::
|
|
601
|
+
|
|
602
|
+
level0segs = [polygon0, polygon1, ...]
|
|
603
|
+
polygon0 = [[x0, y0], [x1, y1], ...]
|
|
604
|
+
|
|
605
|
+
allkinds : ``None`` or [level0kinds, level1kinds, ...]
|
|
606
|
+
Optional list of all the polygon vertex kinds (code types), as
|
|
607
|
+
described and used in Path. This is used to allow multiply-
|
|
608
|
+
connected paths such as holes within filled polygons.
|
|
609
|
+
If not ``None``, ``len(allkinds) == len(allsegs)``. The lists
|
|
610
|
+
should look like ::
|
|
611
|
+
|
|
612
|
+
level0kinds = [polygon0kinds, ...]
|
|
613
|
+
polygon0kinds = [vertexcode0, vertexcode1, ...]
|
|
614
|
+
|
|
615
|
+
If *allkinds* is not ``None``, usually all polygons for a
|
|
616
|
+
particular contour level are grouped together so that
|
|
617
|
+
``level0segs = [polygon0]`` and ``level0kinds = [polygon0kinds]``.
|
|
618
|
+
|
|
619
|
+
**kwargs
|
|
620
|
+
Keyword arguments are as described in the docstring of
|
|
621
|
+
`~.Axes.contour`.
|
|
622
|
+
|
|
623
|
+
%(contour_set_attributes)s
|
|
624
|
+
"""
|
|
625
|
+
|
|
626
|
+
def __init__(self, ax, *args,
|
|
627
|
+
levels=None, filled=False, linewidths=None, linestyles=None,
|
|
628
|
+
hatches=(None,), alpha=None, origin=None, extent=None,
|
|
629
|
+
cmap=None, colors=None, norm=None, vmin=None, vmax=None,
|
|
630
|
+
colorizer=None, extend='neither', antialiased=None, nchunk=0,
|
|
631
|
+
locator=None, transform=None, negative_linestyles=None,
|
|
632
|
+
**kwargs):
|
|
633
|
+
"""
|
|
634
|
+
Draw contour lines or filled regions, depending on
|
|
635
|
+
whether keyword arg *filled* is ``False`` (default) or ``True``.
|
|
636
|
+
|
|
637
|
+
Call signature::
|
|
638
|
+
|
|
639
|
+
ContourSet(ax, levels, allsegs, [allkinds], **kwargs)
|
|
640
|
+
|
|
641
|
+
Parameters
|
|
642
|
+
----------
|
|
643
|
+
ax : `~matplotlib.axes.Axes`
|
|
644
|
+
The `~.axes.Axes` object to draw on.
|
|
645
|
+
|
|
646
|
+
levels : [level0, level1, ..., leveln]
|
|
647
|
+
A list of floating point numbers indicating the contour
|
|
648
|
+
levels.
|
|
649
|
+
|
|
650
|
+
allsegs : [level0segs, level1segs, ...]
|
|
651
|
+
List of all the polygon segments for all the *levels*.
|
|
652
|
+
For contour lines ``len(allsegs) == len(levels)``, and for
|
|
653
|
+
filled contour regions ``len(allsegs) = len(levels)-1``. The lists
|
|
654
|
+
should look like ::
|
|
655
|
+
|
|
656
|
+
level0segs = [polygon0, polygon1, ...]
|
|
657
|
+
polygon0 = [[x0, y0], [x1, y1], ...]
|
|
658
|
+
|
|
659
|
+
allkinds : [level0kinds, level1kinds, ...], optional
|
|
660
|
+
Optional list of all the polygon vertex kinds (code types), as
|
|
661
|
+
described and used in Path. This is used to allow multiply-
|
|
662
|
+
connected paths such as holes within filled polygons.
|
|
663
|
+
If not ``None``, ``len(allkinds) == len(allsegs)``. The lists
|
|
664
|
+
should look like ::
|
|
665
|
+
|
|
666
|
+
level0kinds = [polygon0kinds, ...]
|
|
667
|
+
polygon0kinds = [vertexcode0, vertexcode1, ...]
|
|
668
|
+
|
|
669
|
+
If *allkinds* is not ``None``, usually all polygons for a
|
|
670
|
+
particular contour level are grouped together so that
|
|
671
|
+
``level0segs = [polygon0]`` and ``level0kinds = [polygon0kinds]``.
|
|
672
|
+
|
|
673
|
+
**kwargs
|
|
674
|
+
Keyword arguments are as described in the docstring of
|
|
675
|
+
`~.Axes.contour`.
|
|
676
|
+
"""
|
|
677
|
+
if antialiased is None and filled:
|
|
678
|
+
# Eliminate artifacts; we are not stroking the boundaries.
|
|
679
|
+
antialiased = False
|
|
680
|
+
# The default for line contours will be taken from the
|
|
681
|
+
# LineCollection default, which uses :rc:`lines.antialiased`.
|
|
682
|
+
super().__init__(
|
|
683
|
+
antialiaseds=antialiased,
|
|
684
|
+
alpha=alpha,
|
|
685
|
+
transform=transform,
|
|
686
|
+
colorizer=colorizer,
|
|
687
|
+
)
|
|
688
|
+
self.axes = ax
|
|
689
|
+
self.levels = levels
|
|
690
|
+
self.filled = filled
|
|
691
|
+
self.hatches = hatches
|
|
692
|
+
self.origin = origin
|
|
693
|
+
self.extent = extent
|
|
694
|
+
self.colors = colors
|
|
695
|
+
self.extend = extend
|
|
696
|
+
|
|
697
|
+
self.nchunk = nchunk
|
|
698
|
+
self.locator = locator
|
|
699
|
+
|
|
700
|
+
if "color" in kwargs:
|
|
701
|
+
raise _api.kwarg_error("ContourSet.__init__", "color")
|
|
702
|
+
|
|
703
|
+
if colorizer:
|
|
704
|
+
self._set_colorizer_check_keywords(colorizer, cmap=cmap,
|
|
705
|
+
norm=norm, vmin=vmin,
|
|
706
|
+
vmax=vmax, colors=colors)
|
|
707
|
+
norm = colorizer.norm
|
|
708
|
+
cmap = colorizer.cmap
|
|
709
|
+
if (isinstance(norm, mcolors.LogNorm)
|
|
710
|
+
or isinstance(self.locator, ticker.LogLocator)):
|
|
711
|
+
self.logscale = True
|
|
712
|
+
if norm is None:
|
|
713
|
+
norm = mcolors.LogNorm()
|
|
714
|
+
else:
|
|
715
|
+
self.logscale = False
|
|
716
|
+
|
|
717
|
+
_api.check_in_list([None, 'lower', 'upper', 'image'], origin=origin)
|
|
718
|
+
if self.extent is not None and len(self.extent) != 4:
|
|
719
|
+
raise ValueError(
|
|
720
|
+
"If given, 'extent' must be None or (x0, x1, y0, y1)")
|
|
721
|
+
if self.colors is not None and cmap is not None:
|
|
722
|
+
raise ValueError('Either colors or cmap must be None')
|
|
723
|
+
if self.origin == 'image':
|
|
724
|
+
self.origin = mpl.rcParams['image.origin']
|
|
725
|
+
|
|
726
|
+
self._orig_linestyles = linestyles # Only kept for user access.
|
|
727
|
+
self.negative_linestyles = mpl._val_or_rc(negative_linestyles,
|
|
728
|
+
'contour.negative_linestyle')
|
|
729
|
+
|
|
730
|
+
kwargs = self._process_args(*args, **kwargs)
|
|
731
|
+
self._process_levels()
|
|
732
|
+
|
|
733
|
+
self._extend_min = self.extend in ['min', 'both']
|
|
734
|
+
self._extend_max = self.extend in ['max', 'both']
|
|
735
|
+
if self.colors is not None:
|
|
736
|
+
if mcolors.is_color_like(self.colors):
|
|
737
|
+
color_sequence = [self.colors]
|
|
738
|
+
else:
|
|
739
|
+
color_sequence = self.colors
|
|
740
|
+
|
|
741
|
+
ncolors = len(self.levels)
|
|
742
|
+
if self.filled:
|
|
743
|
+
ncolors -= 1
|
|
744
|
+
i0 = 0
|
|
745
|
+
|
|
746
|
+
# Handle the case where colors are given for the extended
|
|
747
|
+
# parts of the contour.
|
|
748
|
+
|
|
749
|
+
use_set_under_over = False
|
|
750
|
+
# if we are extending the lower end, and we've been given enough
|
|
751
|
+
# colors then skip the first color in the resulting cmap. For the
|
|
752
|
+
# extend_max case we don't need to worry about passing more colors
|
|
753
|
+
# than ncolors as ListedColormap will clip.
|
|
754
|
+
total_levels = (ncolors +
|
|
755
|
+
int(self._extend_min) +
|
|
756
|
+
int(self._extend_max))
|
|
757
|
+
if (len(color_sequence) == total_levels and
|
|
758
|
+
(self._extend_min or self._extend_max)):
|
|
759
|
+
use_set_under_over = True
|
|
760
|
+
if self._extend_min:
|
|
761
|
+
i0 = 1
|
|
762
|
+
|
|
763
|
+
cmap = mcolors.ListedColormap(
|
|
764
|
+
cbook._resize_sequence(color_sequence[i0:], ncolors),
|
|
765
|
+
under=(color_sequence[0]
|
|
766
|
+
if use_set_under_over and self._extend_min else None),
|
|
767
|
+
over=(color_sequence[-1]
|
|
768
|
+
if use_set_under_over and self._extend_max else None),
|
|
769
|
+
)
|
|
770
|
+
|
|
771
|
+
# label lists must be initialized here
|
|
772
|
+
self.labelTexts = []
|
|
773
|
+
self.labelCValues = []
|
|
774
|
+
|
|
775
|
+
self.set_cmap(cmap)
|
|
776
|
+
if norm is not None:
|
|
777
|
+
self.set_norm(norm)
|
|
778
|
+
with self.norm.callbacks.blocked(signal="changed"):
|
|
779
|
+
if vmin is not None:
|
|
780
|
+
self.norm.vmin = vmin
|
|
781
|
+
if vmax is not None:
|
|
782
|
+
self.norm.vmax = vmax
|
|
783
|
+
self.norm._changed()
|
|
784
|
+
self._process_colors()
|
|
785
|
+
|
|
786
|
+
if self._paths is None:
|
|
787
|
+
self._paths = self._make_paths_from_contour_generator()
|
|
788
|
+
|
|
789
|
+
if self.filled:
|
|
790
|
+
if linewidths is not None:
|
|
791
|
+
_api.warn_external('linewidths is ignored by contourf')
|
|
792
|
+
# Lower and upper contour levels.
|
|
793
|
+
lowers, uppers = self._get_lowers_and_uppers()
|
|
794
|
+
self.set(edgecolor="none")
|
|
795
|
+
else:
|
|
796
|
+
self.set(
|
|
797
|
+
facecolor="none",
|
|
798
|
+
linewidths=self._process_linewidths(linewidths),
|
|
799
|
+
linestyle=self._process_linestyles(linestyles),
|
|
800
|
+
label="_nolegend_",
|
|
801
|
+
# Default zorder taken from LineCollection, which is higher
|
|
802
|
+
# than for filled contours so that lines are displayed on top.
|
|
803
|
+
zorder=2,
|
|
804
|
+
)
|
|
805
|
+
self.set(**kwargs) # Let user-set values override defaults.
|
|
806
|
+
|
|
807
|
+
self.axes.add_collection(self, autolim=False)
|
|
808
|
+
self.sticky_edges.x[:] = [self._mins[0], self._maxs[0]]
|
|
809
|
+
self.sticky_edges.y[:] = [self._mins[1], self._maxs[1]]
|
|
810
|
+
self.axes.update_datalim([self._mins, self._maxs])
|
|
811
|
+
self.axes.autoscale_view(tight=True)
|
|
812
|
+
|
|
813
|
+
self.changed() # set the colors
|
|
814
|
+
|
|
815
|
+
allsegs = property(lambda self: [
|
|
816
|
+
[subp.vertices for subp in p._iter_connected_components()]
|
|
817
|
+
for p in self.get_paths()])
|
|
818
|
+
allkinds = property(lambda self: [
|
|
819
|
+
[subp.codes for subp in p._iter_connected_components()]
|
|
820
|
+
for p in self.get_paths()])
|
|
821
|
+
alpha = property(lambda self: self.get_alpha())
|
|
822
|
+
linestyles = property(lambda self: self._orig_linestyles)
|
|
823
|
+
|
|
824
|
+
def get_transform(self):
|
|
825
|
+
"""Return the `.Transform` instance used by this ContourSet."""
|
|
826
|
+
if self._transform is None:
|
|
827
|
+
self._transform = self.axes.transData
|
|
828
|
+
elif (not isinstance(self._transform, mtransforms.Transform)
|
|
829
|
+
and hasattr(self._transform, '_as_mpl_transform')):
|
|
830
|
+
self._transform = self._transform._as_mpl_transform(self.axes)
|
|
831
|
+
return self._transform
|
|
832
|
+
|
|
833
|
+
def __getstate__(self):
|
|
834
|
+
state = self.__dict__.copy()
|
|
835
|
+
# the C object _contour_generator cannot currently be pickled. This
|
|
836
|
+
# isn't a big issue as it is not actually used once the contour has
|
|
837
|
+
# been calculated.
|
|
838
|
+
state['_contour_generator'] = None
|
|
839
|
+
return state
|
|
840
|
+
|
|
841
|
+
def legend_elements(self, variable_name='x', str_format=str):
|
|
842
|
+
"""
|
|
843
|
+
Return a list of artists and labels suitable for passing through
|
|
844
|
+
to `~.Axes.legend` which represent this ContourSet.
|
|
845
|
+
|
|
846
|
+
The labels have the form "0 < x <= 1" stating the data ranges which
|
|
847
|
+
the artists represent.
|
|
848
|
+
|
|
849
|
+
Parameters
|
|
850
|
+
----------
|
|
851
|
+
variable_name : str
|
|
852
|
+
The string used inside the inequality used on the labels.
|
|
853
|
+
str_format : function: float -> str
|
|
854
|
+
Function used to format the numbers in the labels.
|
|
855
|
+
|
|
856
|
+
Returns
|
|
857
|
+
-------
|
|
858
|
+
artists : list[`.Artist`]
|
|
859
|
+
A list of the artists.
|
|
860
|
+
labels : list[str]
|
|
861
|
+
A list of the labels.
|
|
862
|
+
"""
|
|
863
|
+
artists = []
|
|
864
|
+
labels = []
|
|
865
|
+
|
|
866
|
+
if self.filled:
|
|
867
|
+
lowers, uppers = self._get_lowers_and_uppers()
|
|
868
|
+
n_levels = len(self._paths)
|
|
869
|
+
for idx in range(n_levels):
|
|
870
|
+
artists.append(mpatches.Rectangle(
|
|
871
|
+
(0, 0), 1, 1,
|
|
872
|
+
facecolor=self.get_facecolor()[idx],
|
|
873
|
+
hatch=self.hatches[idx % len(self.hatches)],
|
|
874
|
+
))
|
|
875
|
+
lower = str_format(lowers[idx])
|
|
876
|
+
upper = str_format(uppers[idx])
|
|
877
|
+
if idx == 0 and self.extend in ('min', 'both'):
|
|
878
|
+
labels.append(fr'${variable_name} \leq {lower}s$')
|
|
879
|
+
elif idx == n_levels - 1 and self.extend in ('max', 'both'):
|
|
880
|
+
labels.append(fr'${variable_name} > {upper}s$')
|
|
881
|
+
else:
|
|
882
|
+
labels.append(fr'${lower} < {variable_name} \leq {upper}$')
|
|
883
|
+
else:
|
|
884
|
+
for idx, level in enumerate(self.levels):
|
|
885
|
+
artists.append(Line2D(
|
|
886
|
+
[], [],
|
|
887
|
+
color=self.get_edgecolor()[idx],
|
|
888
|
+
linewidth=self.get_linewidths()[idx],
|
|
889
|
+
linestyle=self.get_linestyles()[idx],
|
|
890
|
+
))
|
|
891
|
+
labels.append(fr'${variable_name} = {str_format(level)}$')
|
|
892
|
+
|
|
893
|
+
return artists, labels
|
|
894
|
+
|
|
895
|
+
def _process_args(self, *args, **kwargs):
|
|
896
|
+
"""
|
|
897
|
+
Process *args* and *kwargs*; override in derived classes.
|
|
898
|
+
|
|
899
|
+
Must set self.levels, self.zmin and self.zmax, and update Axes limits.
|
|
900
|
+
"""
|
|
901
|
+
self.levels = args[0]
|
|
902
|
+
allsegs = args[1]
|
|
903
|
+
allkinds = args[2] if len(args) > 2 else None
|
|
904
|
+
self.zmax = np.max(self.levels)
|
|
905
|
+
self.zmin = np.min(self.levels)
|
|
906
|
+
|
|
907
|
+
if allkinds is None:
|
|
908
|
+
allkinds = [[None] * len(segs) for segs in allsegs]
|
|
909
|
+
|
|
910
|
+
# Check lengths of levels and allsegs.
|
|
911
|
+
if self.filled:
|
|
912
|
+
if len(allsegs) != len(self.levels) - 1:
|
|
913
|
+
raise ValueError('must be one less number of segments as '
|
|
914
|
+
'levels')
|
|
915
|
+
else:
|
|
916
|
+
if len(allsegs) != len(self.levels):
|
|
917
|
+
raise ValueError('must be same number of segments as levels')
|
|
918
|
+
|
|
919
|
+
# Check length of allkinds.
|
|
920
|
+
if len(allkinds) != len(allsegs):
|
|
921
|
+
raise ValueError('allkinds has different length to allsegs')
|
|
922
|
+
|
|
923
|
+
# Determine x, y bounds and update axes data limits.
|
|
924
|
+
flatseglist = [s for seg in allsegs for s in seg]
|
|
925
|
+
points = np.concatenate(flatseglist, axis=0)
|
|
926
|
+
self._mins = points.min(axis=0)
|
|
927
|
+
self._maxs = points.max(axis=0)
|
|
928
|
+
|
|
929
|
+
# Each entry in (allsegs, allkinds) is a list of (segs, kinds): segs is a list
|
|
930
|
+
# of (N, 2) arrays of xy coordinates, kinds is a list of arrays of corresponding
|
|
931
|
+
# pathcodes. However, kinds can also be None; in which case all paths in that
|
|
932
|
+
# list are codeless (this case is normalized above). These lists are used to
|
|
933
|
+
# construct paths, which then get concatenated.
|
|
934
|
+
self._paths = [Path.make_compound_path(*map(Path, segs, kinds))
|
|
935
|
+
for segs, kinds in zip(allsegs, allkinds)]
|
|
936
|
+
|
|
937
|
+
return kwargs
|
|
938
|
+
|
|
939
|
+
def _make_paths_from_contour_generator(self):
|
|
940
|
+
"""Compute ``paths`` using C extension."""
|
|
941
|
+
if self._paths is not None:
|
|
942
|
+
return self._paths
|
|
943
|
+
cg = self._contour_generator
|
|
944
|
+
empty_path = Path(np.empty((0, 2)))
|
|
945
|
+
if hasattr(cg, "filled_paths"):
|
|
946
|
+
# matplotlib_rs: all levels at once (on several threads), each
|
|
947
|
+
# level's polygons already concatenated
|
|
948
|
+
lowers, uppers = self._get_lowers_and_uppers()
|
|
949
|
+
paths = (
|
|
950
|
+
cg.filled_paths(list(map(float, lowers)), list(map(float, uppers)))
|
|
951
|
+
if self.filled else
|
|
952
|
+
cg.lines_paths(list(map(float, self.levels))))
|
|
953
|
+
return [empty_path if p is None else Path(*p) for p in paths]
|
|
954
|
+
vertices_and_codes = (
|
|
955
|
+
map(cg.create_filled_contour, *self._get_lowers_and_uppers())
|
|
956
|
+
if self.filled else
|
|
957
|
+
map(cg.create_contour, self.levels))
|
|
958
|
+
return [Path(np.concatenate(vs), np.concatenate(cs)) if len(vs) else empty_path
|
|
959
|
+
for vs, cs in vertices_and_codes]
|
|
960
|
+
|
|
961
|
+
def _get_lowers_and_uppers(self):
|
|
962
|
+
"""
|
|
963
|
+
Return ``(lowers, uppers)`` for filled contours.
|
|
964
|
+
"""
|
|
965
|
+
lowers = self._levels[:-1]
|
|
966
|
+
if self.zmin == lowers[0]:
|
|
967
|
+
# Include minimum values in lowest interval
|
|
968
|
+
lowers = lowers.copy() # so we don't change self._levels
|
|
969
|
+
if self.logscale:
|
|
970
|
+
lowers[0] = 0.99 * self.zmin
|
|
971
|
+
else:
|
|
972
|
+
lowers[0] -= 1
|
|
973
|
+
uppers = self._levels[1:]
|
|
974
|
+
return (lowers, uppers)
|
|
975
|
+
|
|
976
|
+
def changed(self):
|
|
977
|
+
if not hasattr(self, "cvalues"):
|
|
978
|
+
self._process_colors() # Sets cvalues.
|
|
979
|
+
# Force an autoscale immediately because self.to_rgba() calls
|
|
980
|
+
# autoscale_None() internally with the data passed to it,
|
|
981
|
+
# so if vmin/vmax are not set yet, this would override them with
|
|
982
|
+
# content from *cvalues* rather than levels like we want
|
|
983
|
+
self.norm.autoscale_None(self.levels)
|
|
984
|
+
self.set_array(self.cvalues)
|
|
985
|
+
self.update_scalarmappable()
|
|
986
|
+
alphas = np.broadcast_to(self.get_alpha(), len(self.cvalues))
|
|
987
|
+
for label, cv, alpha in zip(self.labelTexts, self.labelCValues, alphas):
|
|
988
|
+
label.set_alpha(alpha)
|
|
989
|
+
label.set_color(self.labelMappable.to_rgba(cv))
|
|
990
|
+
super().changed()
|
|
991
|
+
|
|
992
|
+
def _ensure_locator_exists(self, N):
|
|
993
|
+
"""
|
|
994
|
+
Set a locator on this ContourSet if it's not already set.
|
|
995
|
+
|
|
996
|
+
Parameters
|
|
997
|
+
----------
|
|
998
|
+
N : int or None
|
|
999
|
+
If *N* is an int, it is used as the target number of levels.
|
|
1000
|
+
Otherwise when *N* is None, a reasonable default is chosen;
|
|
1001
|
+
for logscales the LogLocator chooses, N=7 is the default
|
|
1002
|
+
otherwise.
|
|
1003
|
+
"""
|
|
1004
|
+
if self.locator is None:
|
|
1005
|
+
if self.logscale:
|
|
1006
|
+
self.locator = ticker.LogLocator(numticks=N)
|
|
1007
|
+
else:
|
|
1008
|
+
if N is None:
|
|
1009
|
+
N = 7 # Hard coded default
|
|
1010
|
+
self.locator = ticker.MaxNLocator(N + 1, min_n_ticks=1)
|
|
1011
|
+
|
|
1012
|
+
def _autolev(self):
|
|
1013
|
+
"""
|
|
1014
|
+
Select contour levels to span the data.
|
|
1015
|
+
|
|
1016
|
+
We need two more levels for filled contours than for
|
|
1017
|
+
line contours, because for the latter we need to specify
|
|
1018
|
+
the lower and upper boundary of each range. For example,
|
|
1019
|
+
a single contour boundary, say at z = 0, requires only
|
|
1020
|
+
one contour line, but two filled regions, and therefore
|
|
1021
|
+
three levels to provide boundaries for both regions.
|
|
1022
|
+
"""
|
|
1023
|
+
lev = self.locator.tick_values(self.zmin, self.zmax)
|
|
1024
|
+
|
|
1025
|
+
try:
|
|
1026
|
+
if self.locator._symmetric:
|
|
1027
|
+
return lev
|
|
1028
|
+
except AttributeError:
|
|
1029
|
+
pass
|
|
1030
|
+
|
|
1031
|
+
# Trim excess levels the locator may have supplied.
|
|
1032
|
+
under = np.nonzero(lev < self.zmin)[0]
|
|
1033
|
+
i0 = under[-1] if len(under) else 0
|
|
1034
|
+
over = np.nonzero(lev > self.zmax)[0]
|
|
1035
|
+
i1 = over[0] + 1 if len(over) else len(lev)
|
|
1036
|
+
if self.extend in ('min', 'both'):
|
|
1037
|
+
i0 += 1
|
|
1038
|
+
if self.extend in ('max', 'both'):
|
|
1039
|
+
i1 -= 1
|
|
1040
|
+
|
|
1041
|
+
if i1 - i0 < 3:
|
|
1042
|
+
i0, i1 = 0, len(lev)
|
|
1043
|
+
|
|
1044
|
+
return lev[i0:i1]
|
|
1045
|
+
|
|
1046
|
+
def _process_contour_level_args(self, args, z_dtype):
|
|
1047
|
+
"""
|
|
1048
|
+
Determine the contour levels and store in self.levels.
|
|
1049
|
+
"""
|
|
1050
|
+
levels_arg = self.levels
|
|
1051
|
+
if levels_arg is None:
|
|
1052
|
+
if args:
|
|
1053
|
+
# Set if levels manually provided
|
|
1054
|
+
levels_arg = args[0]
|
|
1055
|
+
elif np.issubdtype(z_dtype, bool):
|
|
1056
|
+
# Set default values for bool data types
|
|
1057
|
+
levels_arg = [0, .5, 1] if self.filled else [.5]
|
|
1058
|
+
|
|
1059
|
+
if isinstance(levels_arg, Integral) or levels_arg is None:
|
|
1060
|
+
self._ensure_locator_exists(levels_arg)
|
|
1061
|
+
self.levels = self._autolev()
|
|
1062
|
+
else:
|
|
1063
|
+
self.levels = np.asarray(levels_arg, np.float64)
|
|
1064
|
+
|
|
1065
|
+
if self.filled and len(self.levels) < 2:
|
|
1066
|
+
raise ValueError("Filled contours require at least 2 levels.")
|
|
1067
|
+
if len(self.levels) > 1 and np.min(np.diff(self.levels)) <= 0.0:
|
|
1068
|
+
raise ValueError("Contour levels must be increasing")
|
|
1069
|
+
|
|
1070
|
+
def _process_levels(self):
|
|
1071
|
+
"""
|
|
1072
|
+
Assign values to :attr:`layers` based on :attr:`levels`,
|
|
1073
|
+
adding extended layers as needed if contours are filled.
|
|
1074
|
+
|
|
1075
|
+
For line contours, layers simply coincide with levels;
|
|
1076
|
+
a line is a thin layer. No extended levels are needed
|
|
1077
|
+
with line contours.
|
|
1078
|
+
"""
|
|
1079
|
+
# Make a private _levels to include extended regions; we
|
|
1080
|
+
# want to leave the original levels attribute unchanged.
|
|
1081
|
+
# (Colorbar needs this even for line contours.)
|
|
1082
|
+
self._levels = list(self.levels)
|
|
1083
|
+
|
|
1084
|
+
if self.logscale:
|
|
1085
|
+
lower, upper = 1e-250, 1e250
|
|
1086
|
+
else:
|
|
1087
|
+
lower, upper = -1e250, 1e250
|
|
1088
|
+
|
|
1089
|
+
if self.extend in ('both', 'min'):
|
|
1090
|
+
self._levels.insert(0, lower)
|
|
1091
|
+
if self.extend in ('both', 'max'):
|
|
1092
|
+
self._levels.append(upper)
|
|
1093
|
+
self._levels = np.asarray(self._levels)
|
|
1094
|
+
|
|
1095
|
+
if not self.filled:
|
|
1096
|
+
self.layers = self.levels
|
|
1097
|
+
return
|
|
1098
|
+
|
|
1099
|
+
# Layer values are mid-way between levels in screen space.
|
|
1100
|
+
if self.logscale:
|
|
1101
|
+
# Avoid overflow by taking sqrt before multiplying.
|
|
1102
|
+
self.layers = (np.sqrt(self._levels[:-1])
|
|
1103
|
+
* np.sqrt(self._levels[1:]))
|
|
1104
|
+
else:
|
|
1105
|
+
self.layers = 0.5 * (self._levels[:-1] + self._levels[1:])
|
|
1106
|
+
|
|
1107
|
+
def _process_colors(self):
|
|
1108
|
+
"""
|
|
1109
|
+
Color argument processing for contouring.
|
|
1110
|
+
|
|
1111
|
+
Note that we base the colormapping on the contour levels
|
|
1112
|
+
and layers, not on the actual range of the Z values. This
|
|
1113
|
+
means we don't have to worry about bad values in Z, and we
|
|
1114
|
+
always have the full dynamic range available for the selected
|
|
1115
|
+
levels.
|
|
1116
|
+
|
|
1117
|
+
The color is based on the midpoint of the layer, except for
|
|
1118
|
+
extended end layers. By default, the norm vmin and vmax
|
|
1119
|
+
are the extreme values of the non-extended levels. Hence,
|
|
1120
|
+
the layer color extremes are not the extreme values of
|
|
1121
|
+
the colormap itself, but approach those values as the number
|
|
1122
|
+
of levels increases. An advantage of this scheme is that
|
|
1123
|
+
line contours, when added to filled contours, take on
|
|
1124
|
+
colors that are consistent with those of the filled regions;
|
|
1125
|
+
for example, a contour line on the boundary between two
|
|
1126
|
+
regions will have a color intermediate between those
|
|
1127
|
+
of the regions.
|
|
1128
|
+
|
|
1129
|
+
"""
|
|
1130
|
+
self.monochrome = self.cmap.monochrome
|
|
1131
|
+
if self.colors is not None:
|
|
1132
|
+
# Generate integers for direct indexing.
|
|
1133
|
+
i0, i1 = 0, len(self.levels)
|
|
1134
|
+
if self.filled:
|
|
1135
|
+
i1 -= 1
|
|
1136
|
+
# Out of range indices for over and under:
|
|
1137
|
+
if self.extend in ('both', 'min'):
|
|
1138
|
+
i0 -= 1
|
|
1139
|
+
if self.extend in ('both', 'max'):
|
|
1140
|
+
i1 += 1
|
|
1141
|
+
self.cvalues = list(range(i0, i1))
|
|
1142
|
+
self.set_norm(mcolors.NoNorm())
|
|
1143
|
+
else:
|
|
1144
|
+
self.cvalues = self.layers
|
|
1145
|
+
self.norm.autoscale_None(self.levels)
|
|
1146
|
+
self.set_array(self.cvalues)
|
|
1147
|
+
self.update_scalarmappable()
|
|
1148
|
+
if self.extend in ('both', 'max', 'min'):
|
|
1149
|
+
self.norm.clip = False
|
|
1150
|
+
|
|
1151
|
+
def _process_linewidths(self, linewidths):
|
|
1152
|
+
Nlev = len(self.levels)
|
|
1153
|
+
if linewidths is None:
|
|
1154
|
+
default_linewidth = mpl.rcParams['contour.linewidth']
|
|
1155
|
+
if default_linewidth is None:
|
|
1156
|
+
default_linewidth = mpl.rcParams['lines.linewidth']
|
|
1157
|
+
return [default_linewidth] * Nlev
|
|
1158
|
+
elif not np.iterable(linewidths):
|
|
1159
|
+
return [linewidths] * Nlev
|
|
1160
|
+
else:
|
|
1161
|
+
linewidths = list(linewidths)
|
|
1162
|
+
return (linewidths * math.ceil(Nlev / len(linewidths)))[:Nlev]
|
|
1163
|
+
|
|
1164
|
+
def _process_linestyles(self, linestyles):
|
|
1165
|
+
Nlev = len(self.levels)
|
|
1166
|
+
if linestyles is None:
|
|
1167
|
+
tlinestyles = ['solid'] * Nlev
|
|
1168
|
+
if self.monochrome:
|
|
1169
|
+
eps = - (self.zmax - self.zmin) * 1e-15
|
|
1170
|
+
for i, lev in enumerate(self.levels):
|
|
1171
|
+
if lev < eps:
|
|
1172
|
+
tlinestyles[i] = self.negative_linestyles
|
|
1173
|
+
else:
|
|
1174
|
+
if isinstance(linestyles, str):
|
|
1175
|
+
tlinestyles = [linestyles] * Nlev
|
|
1176
|
+
elif np.iterable(linestyles):
|
|
1177
|
+
tlinestyles = list(linestyles)
|
|
1178
|
+
if len(tlinestyles) < Nlev:
|
|
1179
|
+
nreps = int(np.ceil(Nlev / len(linestyles)))
|
|
1180
|
+
tlinestyles = tlinestyles * nreps
|
|
1181
|
+
if len(tlinestyles) > Nlev:
|
|
1182
|
+
tlinestyles = tlinestyles[:Nlev]
|
|
1183
|
+
else:
|
|
1184
|
+
raise ValueError("Unrecognized type for linestyles kwarg")
|
|
1185
|
+
return tlinestyles
|
|
1186
|
+
|
|
1187
|
+
def _find_nearest_contour(self, xy, indices=None):
|
|
1188
|
+
"""
|
|
1189
|
+
Find the point in the unfilled contour plot that is closest (in screen
|
|
1190
|
+
space) to point *xy*.
|
|
1191
|
+
|
|
1192
|
+
Parameters
|
|
1193
|
+
----------
|
|
1194
|
+
xy : tuple[float, float]
|
|
1195
|
+
The reference point (in screen space).
|
|
1196
|
+
indices : list of int or None, default: None
|
|
1197
|
+
Indices of contour levels to consider. If None (the default), all levels
|
|
1198
|
+
are considered.
|
|
1199
|
+
|
|
1200
|
+
Returns
|
|
1201
|
+
-------
|
|
1202
|
+
idx_level_min : int
|
|
1203
|
+
The index of the contour level closest to *xy*.
|
|
1204
|
+
idx_vtx_min : int
|
|
1205
|
+
The index of the `.Path` segment closest to *xy* (at that level).
|
|
1206
|
+
proj : (float, float)
|
|
1207
|
+
The point in the contour plot closest to *xy*.
|
|
1208
|
+
"""
|
|
1209
|
+
|
|
1210
|
+
# Convert each contour segment to pixel coordinates and then compare the given
|
|
1211
|
+
# point to those coordinates for each contour. This is fast enough in normal
|
|
1212
|
+
# cases, but speedups may be possible.
|
|
1213
|
+
|
|
1214
|
+
if self.filled:
|
|
1215
|
+
raise ValueError("Method does not support filled contours")
|
|
1216
|
+
|
|
1217
|
+
if indices is None:
|
|
1218
|
+
indices = range(len(self._paths))
|
|
1219
|
+
|
|
1220
|
+
d2min = np.inf
|
|
1221
|
+
idx_level_min = idx_vtx_min = proj_min = None
|
|
1222
|
+
|
|
1223
|
+
for idx_level in indices:
|
|
1224
|
+
path = self._paths[idx_level]
|
|
1225
|
+
idx_vtx_start = 0
|
|
1226
|
+
for subpath in path._iter_connected_components():
|
|
1227
|
+
if not len(subpath.vertices):
|
|
1228
|
+
continue
|
|
1229
|
+
lc = self.get_transform().transform(subpath.vertices)
|
|
1230
|
+
d2, proj, leg = _find_closest_point_on_path(lc, xy)
|
|
1231
|
+
if d2 < d2min:
|
|
1232
|
+
d2min = d2
|
|
1233
|
+
idx_level_min = idx_level
|
|
1234
|
+
idx_vtx_min = leg[1] + idx_vtx_start
|
|
1235
|
+
proj_min = proj
|
|
1236
|
+
idx_vtx_start += len(subpath)
|
|
1237
|
+
|
|
1238
|
+
return idx_level_min, idx_vtx_min, proj_min
|
|
1239
|
+
|
|
1240
|
+
def find_nearest_contour(self, x, y, indices=None, pixel=True):
|
|
1241
|
+
"""
|
|
1242
|
+
Find the point in the contour plot that is closest to ``(x, y)``.
|
|
1243
|
+
|
|
1244
|
+
This method does not support filled contours.
|
|
1245
|
+
|
|
1246
|
+
Parameters
|
|
1247
|
+
----------
|
|
1248
|
+
x, y : float
|
|
1249
|
+
The reference point.
|
|
1250
|
+
indices : list of int or None, default: None
|
|
1251
|
+
Indices of contour levels to consider. If None (the default), all
|
|
1252
|
+
levels are considered.
|
|
1253
|
+
pixel : bool, default: True
|
|
1254
|
+
If *True*, measure distance in pixel (screen) space, which is
|
|
1255
|
+
useful for manual contour labeling; else, measure distance in axes
|
|
1256
|
+
space.
|
|
1257
|
+
|
|
1258
|
+
Returns
|
|
1259
|
+
-------
|
|
1260
|
+
path : int
|
|
1261
|
+
The index of the path that is closest to ``(x, y)``. Each path corresponds
|
|
1262
|
+
to one contour level.
|
|
1263
|
+
subpath : int
|
|
1264
|
+
The index within that closest path of the subpath that is closest to
|
|
1265
|
+
``(x, y)``. Each subpath corresponds to one unbroken contour line.
|
|
1266
|
+
index : int
|
|
1267
|
+
The index of the vertices within that subpath that are closest to
|
|
1268
|
+
``(x, y)``.
|
|
1269
|
+
xmin, ymin : float
|
|
1270
|
+
The point in the contour plot that is closest to ``(x, y)``.
|
|
1271
|
+
d2 : float
|
|
1272
|
+
The squared distance from ``(xmin, ymin)`` to ``(x, y)``.
|
|
1273
|
+
"""
|
|
1274
|
+
segment = index = d2 = None
|
|
1275
|
+
|
|
1276
|
+
with ExitStack() as stack:
|
|
1277
|
+
if not pixel:
|
|
1278
|
+
# _find_nearest_contour works in pixel space. We want axes space, so
|
|
1279
|
+
# effectively disable the transformation here by setting to identity.
|
|
1280
|
+
stack.enter_context(self._cm_set(
|
|
1281
|
+
transform=mtransforms.IdentityTransform()))
|
|
1282
|
+
|
|
1283
|
+
i_level, i_vtx, (xmin, ymin) = self._find_nearest_contour((x, y), indices)
|
|
1284
|
+
|
|
1285
|
+
if i_level is not None:
|
|
1286
|
+
cc_cumlens = np.cumsum(
|
|
1287
|
+
[*map(len, self._paths[i_level]._iter_connected_components())])
|
|
1288
|
+
segment = cc_cumlens.searchsorted(i_vtx, "right")
|
|
1289
|
+
index = i_vtx if segment == 0 else i_vtx - cc_cumlens[segment - 1]
|
|
1290
|
+
d2 = (xmin-x)**2 + (ymin-y)**2
|
|
1291
|
+
|
|
1292
|
+
return (i_level, segment, index, xmin, ymin, d2)
|
|
1293
|
+
|
|
1294
|
+
@artist.allow_rasterization
|
|
1295
|
+
def draw(self, renderer):
|
|
1296
|
+
paths = self._paths
|
|
1297
|
+
n_paths = len(paths)
|
|
1298
|
+
if not self.filled or all(hatch is None for hatch in self.hatches):
|
|
1299
|
+
super().draw(renderer)
|
|
1300
|
+
return
|
|
1301
|
+
# In presence of hatching, draw contours one at a time.
|
|
1302
|
+
edgecolors = self.get_edgecolors()
|
|
1303
|
+
if edgecolors.size == 0:
|
|
1304
|
+
edgecolors = ("none",)
|
|
1305
|
+
for idx in range(n_paths):
|
|
1306
|
+
with self._cm_set(
|
|
1307
|
+
paths=[paths[idx]],
|
|
1308
|
+
hatch=self.hatches[idx % len(self.hatches)],
|
|
1309
|
+
array=[self.get_array()[idx]],
|
|
1310
|
+
linewidths=[self.get_linewidths()[idx % len(self.get_linewidths())]],
|
|
1311
|
+
linestyles=[self.get_linestyles()[idx % len(self.get_linestyles())]],
|
|
1312
|
+
edgecolors=edgecolors[idx % len(edgecolors)],
|
|
1313
|
+
):
|
|
1314
|
+
super().draw(renderer)
|
|
1315
|
+
|
|
1316
|
+
|
|
1317
|
+
@_docstring.interpd
|
|
1318
|
+
class QuadContourSet(ContourSet):
|
|
1319
|
+
"""
|
|
1320
|
+
Create and store a set of contour lines or filled regions.
|
|
1321
|
+
|
|
1322
|
+
This class is typically not instantiated directly by the user but by
|
|
1323
|
+
`~.Axes.contour` and `~.Axes.contourf`.
|
|
1324
|
+
|
|
1325
|
+
%(contour_set_attributes)s
|
|
1326
|
+
"""
|
|
1327
|
+
|
|
1328
|
+
def _process_args(self, *args, corner_mask=None, algorithm=None, **kwargs):
|
|
1329
|
+
"""
|
|
1330
|
+
Process args and kwargs.
|
|
1331
|
+
"""
|
|
1332
|
+
if args and isinstance(args[0], QuadContourSet):
|
|
1333
|
+
if self.levels is None:
|
|
1334
|
+
self.levels = args[0].levels
|
|
1335
|
+
self.zmin = args[0].zmin
|
|
1336
|
+
self.zmax = args[0].zmax
|
|
1337
|
+
self._corner_mask = args[0]._corner_mask
|
|
1338
|
+
contour_generator = args[0]._contour_generator
|
|
1339
|
+
self._mins = args[0]._mins
|
|
1340
|
+
self._maxs = args[0]._maxs
|
|
1341
|
+
self._algorithm = args[0]._algorithm
|
|
1342
|
+
else:
|
|
1343
|
+
from matplotlib_rs import _contour
|
|
1344
|
+
|
|
1345
|
+
algorithm = mpl._val_or_rc(algorithm, 'contour.algorithm')
|
|
1346
|
+
mpl.rcParams.validate["contour.algorithm"](algorithm)
|
|
1347
|
+
self._algorithm = algorithm
|
|
1348
|
+
|
|
1349
|
+
if corner_mask is None:
|
|
1350
|
+
if self._algorithm == "mpl2005":
|
|
1351
|
+
# mpl2005 does not support corner_mask=True so if not
|
|
1352
|
+
# specifically requested then disable it.
|
|
1353
|
+
corner_mask = False
|
|
1354
|
+
else:
|
|
1355
|
+
corner_mask = mpl.rcParams['contour.corner_mask']
|
|
1356
|
+
self._corner_mask = corner_mask
|
|
1357
|
+
|
|
1358
|
+
x, y, z = self._contour_args(args, kwargs)
|
|
1359
|
+
|
|
1360
|
+
# contourpy if installed, else the built-in mpl2014 algorithm
|
|
1361
|
+
contour_generator = _contour.contour_generator(
|
|
1362
|
+
x, y, z, name=self._algorithm, corner_mask=self._corner_mask,
|
|
1363
|
+
chunk_size=self.nchunk)
|
|
1364
|
+
|
|
1365
|
+
t = self.get_transform()
|
|
1366
|
+
|
|
1367
|
+
# if the transform is not trans data, and some part of it
|
|
1368
|
+
# contains transData, transform the xs and ys to data coordinates
|
|
1369
|
+
if (t != self.axes.transData and
|
|
1370
|
+
any(t.contains_branch_separately(self.axes.transData))):
|
|
1371
|
+
trans_to_data = t - self.axes.transData
|
|
1372
|
+
pts = np.vstack([x.flat, y.flat]).T
|
|
1373
|
+
transformed_pts = trans_to_data.transform(pts)
|
|
1374
|
+
x = transformed_pts[..., 0]
|
|
1375
|
+
y = transformed_pts[..., 1]
|
|
1376
|
+
|
|
1377
|
+
self._mins = [ma.min(x), ma.min(y)]
|
|
1378
|
+
self._maxs = [ma.max(x), ma.max(y)]
|
|
1379
|
+
|
|
1380
|
+
self._contour_generator = contour_generator
|
|
1381
|
+
|
|
1382
|
+
return kwargs
|
|
1383
|
+
|
|
1384
|
+
def _contour_args(self, args, kwargs):
|
|
1385
|
+
if self.filled:
|
|
1386
|
+
fn = 'contourf'
|
|
1387
|
+
else:
|
|
1388
|
+
fn = 'contour'
|
|
1389
|
+
nargs = len(args)
|
|
1390
|
+
|
|
1391
|
+
if 0 < nargs <= 2:
|
|
1392
|
+
z, *args = args
|
|
1393
|
+
z = ma.asarray(z)
|
|
1394
|
+
x, y = self._initialize_x_y(z)
|
|
1395
|
+
elif 2 < nargs <= 4:
|
|
1396
|
+
x, y, z_orig, *args = args
|
|
1397
|
+
x, y, z = self._check_xyz(x, y, z_orig, kwargs)
|
|
1398
|
+
|
|
1399
|
+
else:
|
|
1400
|
+
raise _api.nargs_error(fn, takes="from 1 to 4", given=nargs)
|
|
1401
|
+
z = ma.masked_invalid(z, copy=False)
|
|
1402
|
+
self.zmax = z.max().astype(float)
|
|
1403
|
+
self.zmin = z.min().astype(float)
|
|
1404
|
+
if self.logscale and self.zmin <= 0:
|
|
1405
|
+
z = ma.masked_where(z <= 0, z)
|
|
1406
|
+
_api.warn_external('Log scale: values of z <= 0 have been masked')
|
|
1407
|
+
self.zmin = z.min().astype(float)
|
|
1408
|
+
self._process_contour_level_args(args, z.dtype)
|
|
1409
|
+
return (x, y, z)
|
|
1410
|
+
|
|
1411
|
+
def _check_xyz(self, x, y, z, kwargs):
|
|
1412
|
+
"""
|
|
1413
|
+
Check that the shapes of the input arrays match; if x and y are 1D,
|
|
1414
|
+
convert them to 2D using meshgrid.
|
|
1415
|
+
"""
|
|
1416
|
+
x, y = self.axes._process_unit_info([("x", x), ("y", y)], kwargs)
|
|
1417
|
+
|
|
1418
|
+
x = np.asarray(x, dtype=np.float64)
|
|
1419
|
+
y = np.asarray(y, dtype=np.float64)
|
|
1420
|
+
z = ma.asarray(z)
|
|
1421
|
+
|
|
1422
|
+
if z.ndim != 2:
|
|
1423
|
+
raise TypeError(f"Input z must be 2D, not {z.ndim}D")
|
|
1424
|
+
if z.shape[0] < 2 or z.shape[1] < 2:
|
|
1425
|
+
raise TypeError(f"Input z must be at least a (2, 2) shaped array, "
|
|
1426
|
+
f"but has shape {z.shape}")
|
|
1427
|
+
Ny, Nx = z.shape
|
|
1428
|
+
|
|
1429
|
+
if x.ndim != y.ndim:
|
|
1430
|
+
raise TypeError(f"Number of dimensions of x ({x.ndim}) and y "
|
|
1431
|
+
f"({y.ndim}) do not match")
|
|
1432
|
+
if x.ndim == 1:
|
|
1433
|
+
nx, = x.shape
|
|
1434
|
+
ny, = y.shape
|
|
1435
|
+
if nx != Nx:
|
|
1436
|
+
raise TypeError(f"Length of x ({nx}) must match number of "
|
|
1437
|
+
f"columns in z ({Nx})")
|
|
1438
|
+
if ny != Ny:
|
|
1439
|
+
raise TypeError(f"Length of y ({ny}) must match number of "
|
|
1440
|
+
f"rows in z ({Ny})")
|
|
1441
|
+
x, y = np.meshgrid(x, y)
|
|
1442
|
+
elif x.ndim == 2:
|
|
1443
|
+
if x.shape != z.shape:
|
|
1444
|
+
raise TypeError(
|
|
1445
|
+
f"Shapes of x {x.shape} and z {z.shape} do not match")
|
|
1446
|
+
if y.shape != z.shape:
|
|
1447
|
+
raise TypeError(
|
|
1448
|
+
f"Shapes of y {y.shape} and z {z.shape} do not match")
|
|
1449
|
+
else:
|
|
1450
|
+
raise TypeError(f"Inputs x and y must be 1D or 2D, not {x.ndim}D")
|
|
1451
|
+
|
|
1452
|
+
return x, y, z
|
|
1453
|
+
|
|
1454
|
+
def _initialize_x_y(self, z):
|
|
1455
|
+
"""
|
|
1456
|
+
Return X, Y arrays such that contour(Z) will match imshow(Z)
|
|
1457
|
+
if origin is not None.
|
|
1458
|
+
The center of pixel Z[i, j] depends on origin:
|
|
1459
|
+
if origin is None, x = j, y = i;
|
|
1460
|
+
if origin is 'lower', x = j + 0.5, y = i + 0.5;
|
|
1461
|
+
if origin is 'upper', x = j + 0.5, y = Nrows - i - 0.5
|
|
1462
|
+
If extent is not None, x and y will be scaled to match,
|
|
1463
|
+
as in imshow.
|
|
1464
|
+
If origin is None and extent is not None, then extent
|
|
1465
|
+
will give the minimum and maximum values of x and y.
|
|
1466
|
+
"""
|
|
1467
|
+
if z.ndim != 2:
|
|
1468
|
+
raise TypeError(f"Input z must be 2D, not {z.ndim}D")
|
|
1469
|
+
elif z.shape[0] < 2 or z.shape[1] < 2:
|
|
1470
|
+
raise TypeError(f"Input z must be at least a (2, 2) shaped array, "
|
|
1471
|
+
f"but has shape {z.shape}")
|
|
1472
|
+
else:
|
|
1473
|
+
Ny, Nx = z.shape
|
|
1474
|
+
if self.origin is None: # Not for image-matching.
|
|
1475
|
+
if self.extent is None:
|
|
1476
|
+
return np.meshgrid(np.arange(Nx), np.arange(Ny))
|
|
1477
|
+
else:
|
|
1478
|
+
x0, x1, y0, y1 = self.extent
|
|
1479
|
+
x = np.linspace(x0, x1, Nx)
|
|
1480
|
+
y = np.linspace(y0, y1, Ny)
|
|
1481
|
+
return np.meshgrid(x, y)
|
|
1482
|
+
# Match image behavior:
|
|
1483
|
+
if self.extent is None:
|
|
1484
|
+
x0, x1, y0, y1 = (0, Nx, 0, Ny)
|
|
1485
|
+
else:
|
|
1486
|
+
x0, x1, y0, y1 = self.extent
|
|
1487
|
+
dx = (x1 - x0) / Nx
|
|
1488
|
+
dy = (y1 - y0) / Ny
|
|
1489
|
+
x = x0 + (np.arange(Nx) + 0.5) * dx
|
|
1490
|
+
y = y0 + (np.arange(Ny) + 0.5) * dy
|
|
1491
|
+
if self.origin == 'upper':
|
|
1492
|
+
y = y[::-1]
|
|
1493
|
+
return np.meshgrid(x, y)
|
|
1494
|
+
|
|
1495
|
+
|
|
1496
|
+
_docstring.interpd.register(contour_doc="""
|
|
1497
|
+
`.contour` and `.contourf` draw contour lines and filled contours,
|
|
1498
|
+
respectively. Except as noted, function signatures and return values
|
|
1499
|
+
are the same for both versions.
|
|
1500
|
+
|
|
1501
|
+
Parameters
|
|
1502
|
+
----------
|
|
1503
|
+
X, Y : array-like, optional
|
|
1504
|
+
The coordinates of the values in *Z*.
|
|
1505
|
+
|
|
1506
|
+
*X* and *Y* must both be 2D with the same shape as *Z* (e.g.
|
|
1507
|
+
created via `numpy.meshgrid`), or they must both be 1-D such
|
|
1508
|
+
that ``len(X) == N`` is the number of columns in *Z* and
|
|
1509
|
+
``len(Y) == M`` is the number of rows in *Z*.
|
|
1510
|
+
|
|
1511
|
+
*X* and *Y* must both be ordered monotonically.
|
|
1512
|
+
|
|
1513
|
+
If not given, they are assumed to be integer indices, i.e.
|
|
1514
|
+
``X = range(N)``, ``Y = range(M)``.
|
|
1515
|
+
|
|
1516
|
+
Z : (M, N) array-like
|
|
1517
|
+
The height values over which the contour is drawn. Color-mapping is
|
|
1518
|
+
controlled by *cmap*, *norm*, *vmin*, and *vmax*.
|
|
1519
|
+
|
|
1520
|
+
levels : int or array-like, optional
|
|
1521
|
+
Determines the number and positions of the contour lines / regions.
|
|
1522
|
+
|
|
1523
|
+
If an int *n*, use `~matplotlib.ticker.MaxNLocator`, which tries to
|
|
1524
|
+
automatically choose no more than *n+2* "nice" contour level boundaries
|
|
1525
|
+
between the minimum and maximum numeric values of *Z*. These boundaries
|
|
1526
|
+
define where lines are drawn (for `contour`) or where filled regions
|
|
1527
|
+
are separated (for `contourf`).
|
|
1528
|
+
|
|
1529
|
+
If not given, a reasonable default is chosen; for linear scales,
|
|
1530
|
+
*n*=7 is the default.
|
|
1531
|
+
|
|
1532
|
+
If array-like, draw contour lines at the specified levels.
|
|
1533
|
+
The values must be in increasing order.
|
|
1534
|
+
|
|
1535
|
+
If not specified, a reasonable default is automatically chosen. For
|
|
1536
|
+
linear scales, this corresponds to *levels=7*. For logarithmic
|
|
1537
|
+
scales, `~matplotlib.ticker.LogLocator` is used instead.
|
|
1538
|
+
|
|
1539
|
+
Returns
|
|
1540
|
+
-------
|
|
1541
|
+
`~.contour.QuadContourSet`
|
|
1542
|
+
|
|
1543
|
+
Other Parameters
|
|
1544
|
+
----------------
|
|
1545
|
+
corner_mask : bool, default: :rc:`contour.corner_mask`
|
|
1546
|
+
Enable/disable corner masking, which only has an effect if *Z* is
|
|
1547
|
+
a masked array. If ``False``, any quad touching a masked point is
|
|
1548
|
+
masked out. If ``True``, only the triangular corners of quads
|
|
1549
|
+
nearest those points are always masked out, other triangular
|
|
1550
|
+
corners comprising three unmasked points are contoured as usual.
|
|
1551
|
+
|
|
1552
|
+
colors : :mpltype:`color` or list of :mpltype:`color`, optional
|
|
1553
|
+
The colors of the levels, i.e. the lines for `.contour` and the
|
|
1554
|
+
areas for `.contourf`.
|
|
1555
|
+
|
|
1556
|
+
The sequence is cycled for the levels in ascending order. If the
|
|
1557
|
+
sequence is shorter than the number of levels, it's repeated.
|
|
1558
|
+
|
|
1559
|
+
As a shortcut, a single color may be used in place of one-element lists, i.e.
|
|
1560
|
+
``'red'`` instead of ``['red']`` to color all levels with the same color.
|
|
1561
|
+
|
|
1562
|
+
.. versionchanged:: 3.10
|
|
1563
|
+
Previously a single color had to be expressed as a string, but now any
|
|
1564
|
+
valid color format may be passed.
|
|
1565
|
+
|
|
1566
|
+
By default (value *None*), the colormap specified by *cmap*
|
|
1567
|
+
will be used.
|
|
1568
|
+
|
|
1569
|
+
alpha : float, default: 1
|
|
1570
|
+
The alpha blending value, between 0 (transparent) and 1 (opaque).
|
|
1571
|
+
|
|
1572
|
+
%(cmap_doc)s
|
|
1573
|
+
|
|
1574
|
+
This parameter is ignored if *colors* is set.
|
|
1575
|
+
|
|
1576
|
+
%(norm_doc)s
|
|
1577
|
+
|
|
1578
|
+
This parameter is ignored if *colors* is set.
|
|
1579
|
+
|
|
1580
|
+
%(vmin_vmax_doc)s
|
|
1581
|
+
|
|
1582
|
+
If *vmin* or *vmax* are not given, the default color scaling is based on
|
|
1583
|
+
*levels*.
|
|
1584
|
+
|
|
1585
|
+
This parameter is ignored if *colors* is set.
|
|
1586
|
+
|
|
1587
|
+
%(colorizer_doc)s
|
|
1588
|
+
|
|
1589
|
+
This parameter is ignored if *colors* is set.
|
|
1590
|
+
|
|
1591
|
+
origin : {*None*, 'upper', 'lower', 'image'}, default: None
|
|
1592
|
+
Determines the orientation and exact position of *Z* by specifying
|
|
1593
|
+
the position of ``Z[0, 0]``. This is only relevant, if *X*, *Y*
|
|
1594
|
+
are not given.
|
|
1595
|
+
|
|
1596
|
+
- *None*: ``Z[0, 0]`` is at X=0, Y=0 in the lower left corner.
|
|
1597
|
+
- 'lower': ``Z[0, 0]`` is at X=0.5, Y=0.5 in the lower left corner.
|
|
1598
|
+
- 'upper': ``Z[0, 0]`` is at X=N+0.5, Y=0.5 in the upper left
|
|
1599
|
+
corner.
|
|
1600
|
+
- 'image': Use the value from :rc:`image.origin`.
|
|
1601
|
+
|
|
1602
|
+
extent : (x0, x1, y0, y1), optional
|
|
1603
|
+
If *origin* is not *None*, then *extent* is interpreted as in
|
|
1604
|
+
`.imshow`: it gives the outer pixel boundaries. In this case, the
|
|
1605
|
+
position of Z[0, 0] is the center of the pixel, not a corner. If
|
|
1606
|
+
*origin* is *None*, then (*x0*, *y0*) is the position of Z[0, 0],
|
|
1607
|
+
and (*x1*, *y1*) is the position of Z[-1, -1].
|
|
1608
|
+
|
|
1609
|
+
This argument is ignored if *X* and *Y* are specified in the call
|
|
1610
|
+
to contour.
|
|
1611
|
+
|
|
1612
|
+
locator : ticker.Locator subclass, optional
|
|
1613
|
+
The locator is used to determine the contour levels if they
|
|
1614
|
+
are not given explicitly via *levels*.
|
|
1615
|
+
Defaults to `~.ticker.MaxNLocator`.
|
|
1616
|
+
|
|
1617
|
+
extend : {'neither', 'both', 'min', 'max'}, default: 'neither'
|
|
1618
|
+
Determines the ``contourf``-coloring of values that are outside the
|
|
1619
|
+
*levels* range.
|
|
1620
|
+
|
|
1621
|
+
If 'neither', values outside the *levels* range are not colored.
|
|
1622
|
+
If 'min', 'max' or 'both', color the values below, above or below
|
|
1623
|
+
and above the *levels* range.
|
|
1624
|
+
|
|
1625
|
+
Values below ``min(levels)`` and above ``max(levels)`` are mapped
|
|
1626
|
+
to the under/over values of the `.Colormap`. Note that most
|
|
1627
|
+
colormaps do not have dedicated colors for these by default, so
|
|
1628
|
+
that the over and under values are the edge values of the colormap.
|
|
1629
|
+
You may want to set these values explicitly using
|
|
1630
|
+
`.Colormap.set_under` and `.Colormap.set_over`.
|
|
1631
|
+
|
|
1632
|
+
.. note::
|
|
1633
|
+
|
|
1634
|
+
An existing `.QuadContourSet` does not get notified if
|
|
1635
|
+
properties of its colormap are changed. Therefore, an explicit
|
|
1636
|
+
call `~.ContourSet.changed()` is needed after modifying the
|
|
1637
|
+
colormap. The explicit call can be left out, if a colorbar is
|
|
1638
|
+
assigned to the `.QuadContourSet` because it internally calls
|
|
1639
|
+
`~.ContourSet.changed()`.
|
|
1640
|
+
|
|
1641
|
+
Example::
|
|
1642
|
+
|
|
1643
|
+
x = np.arange(1, 10)
|
|
1644
|
+
y = x.reshape(-1, 1)
|
|
1645
|
+
h = x * y
|
|
1646
|
+
|
|
1647
|
+
cs = plt.contourf(h, levels=[10, 30, 50],
|
|
1648
|
+
colors=['#808080', '#A0A0A0', '#C0C0C0'], extend='both')
|
|
1649
|
+
cs.cmap.set_over('red')
|
|
1650
|
+
cs.cmap.set_under('blue')
|
|
1651
|
+
cs.changed()
|
|
1652
|
+
|
|
1653
|
+
xunits, yunits : registered units, optional
|
|
1654
|
+
Override axis units by specifying an instance of a
|
|
1655
|
+
:class:`matplotlib.units.ConversionInterface`.
|
|
1656
|
+
|
|
1657
|
+
antialiased : bool, optional
|
|
1658
|
+
Enable antialiasing, overriding the defaults. For
|
|
1659
|
+
filled contours, the default is *False*. For line contours,
|
|
1660
|
+
it is taken from :rc:`lines.antialiased`.
|
|
1661
|
+
|
|
1662
|
+
nchunk : int >= 0, optional
|
|
1663
|
+
If 0, no subdivision of the domain. Specify a positive integer to
|
|
1664
|
+
divide the domain into subdomains of *nchunk* by *nchunk* quads.
|
|
1665
|
+
Chunking reduces the maximum length of polygons generated by the
|
|
1666
|
+
contouring algorithm which reduces the rendering workload passed
|
|
1667
|
+
on to the backend and also requires slightly less RAM. It can
|
|
1668
|
+
however introduce rendering artifacts at chunk boundaries depending
|
|
1669
|
+
on the backend, the *antialiased* flag and value of *alpha*.
|
|
1670
|
+
|
|
1671
|
+
linewidths : float or array-like, default: :rc:`contour.linewidth`
|
|
1672
|
+
*Only applies to* `.contour`.
|
|
1673
|
+
|
|
1674
|
+
The line width of the contour lines.
|
|
1675
|
+
|
|
1676
|
+
If a number, all levels will be plotted with this linewidth.
|
|
1677
|
+
|
|
1678
|
+
If a sequence, the levels in ascending order will be plotted with
|
|
1679
|
+
the linewidths in the order specified.
|
|
1680
|
+
|
|
1681
|
+
If None, this falls back to :rc:`lines.linewidth`.
|
|
1682
|
+
|
|
1683
|
+
linestyles : {*None*, 'solid', 'dashed', 'dashdot', 'dotted'}, optional
|
|
1684
|
+
*Only applies to* `.contour`.
|
|
1685
|
+
|
|
1686
|
+
If *linestyles* is *None*, the default is 'solid' unless the lines are
|
|
1687
|
+
monochrome. In that case, negative contours will instead take their
|
|
1688
|
+
linestyle from the *negative_linestyles* argument.
|
|
1689
|
+
|
|
1690
|
+
*linestyles* can also be an iterable of the above strings specifying a set
|
|
1691
|
+
of linestyles to be used. If this iterable is shorter than the number of
|
|
1692
|
+
contour levels it will be repeated as necessary.
|
|
1693
|
+
|
|
1694
|
+
negative_linestyles : {*None*, 'solid', 'dashed', 'dashdot', 'dotted'}, \
|
|
1695
|
+
optional
|
|
1696
|
+
*Only applies to* `.contour`.
|
|
1697
|
+
|
|
1698
|
+
If *linestyles* is *None* and the lines are monochrome, this argument
|
|
1699
|
+
specifies the line style for negative contours.
|
|
1700
|
+
|
|
1701
|
+
If *negative_linestyles* is *None*, the default is taken from
|
|
1702
|
+
:rc:`contour.negative_linestyle`.
|
|
1703
|
+
|
|
1704
|
+
*negative_linestyles* can also be an iterable of the above strings
|
|
1705
|
+
specifying a set of linestyles to be used. If this iterable is shorter than
|
|
1706
|
+
the number of contour levels it will be repeated as necessary.
|
|
1707
|
+
|
|
1708
|
+
hatches : list[str], optional
|
|
1709
|
+
*Only applies to* `.contourf`.
|
|
1710
|
+
|
|
1711
|
+
A list of cross hatch patterns to use on the filled areas.
|
|
1712
|
+
If None, no hatching will be added to the contour.
|
|
1713
|
+
|
|
1714
|
+
algorithm : {'mpl2005', 'mpl2014', 'serial', 'threaded'}, optional
|
|
1715
|
+
Which contouring algorithm to use to calculate the contour lines and
|
|
1716
|
+
polygons. The algorithms are implemented in
|
|
1717
|
+
`ContourPy <https://github.com/contourpy/contourpy>`_, consult the
|
|
1718
|
+
`ContourPy documentation <https://contourpy.readthedocs.io>`_ for
|
|
1719
|
+
further information.
|
|
1720
|
+
|
|
1721
|
+
The default is taken from :rc:`contour.algorithm`.
|
|
1722
|
+
|
|
1723
|
+
clip_path : `~matplotlib.patches.Patch` or `.Path` or `.TransformedPath`
|
|
1724
|
+
Set the clip path. See `~matplotlib.artist.Artist.set_clip_path`.
|
|
1725
|
+
|
|
1726
|
+
.. versionadded:: 3.8
|
|
1727
|
+
|
|
1728
|
+
data : indexable object, optional
|
|
1729
|
+
DATA_PARAMETER_PLACEHOLDER
|
|
1730
|
+
|
|
1731
|
+
rasterized : bool, optional
|
|
1732
|
+
*Only applies to* `.contourf`.
|
|
1733
|
+
Rasterize the contour plot when drawing vector graphics. This can
|
|
1734
|
+
speed up rendering and produce smaller files for large data sets.
|
|
1735
|
+
See also :doc:`/gallery/misc/rasterization_demo`.
|
|
1736
|
+
|
|
1737
|
+
|
|
1738
|
+
Notes
|
|
1739
|
+
-----
|
|
1740
|
+
1. `.contourf` differs from the MATLAB version in that it does not draw
|
|
1741
|
+
the polygon edges. To draw edges, add line contours with calls to
|
|
1742
|
+
`.contour`.
|
|
1743
|
+
|
|
1744
|
+
2. `.contourf` fills intervals that are closed at the top; that is, for
|
|
1745
|
+
boundaries *z1* and *z2*, the filled region is::
|
|
1746
|
+
|
|
1747
|
+
z1 < Z <= z2
|
|
1748
|
+
|
|
1749
|
+
except for the lowest interval, which is closed on both sides (i.e.
|
|
1750
|
+
it includes the lowest value).
|
|
1751
|
+
|
|
1752
|
+
3. `.contour` and `.contourf` use a `marching squares
|
|
1753
|
+
<https://en.wikipedia.org/wiki/Marching_squares>`_ algorithm to
|
|
1754
|
+
compute contour locations. More information can be found in
|
|
1755
|
+
`ContourPy documentation <https://contourpy.readthedocs.io>`_.
|
|
1756
|
+
""" % _docstring.interpd.params)
|