matplotlib-rs 0.0.8__cp313-cp313-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.cp313-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/lines.py
ADDED
|
@@ -0,0 +1,1886 @@
|
|
|
1
|
+
# Vendored from matplotlib 3.11 (see licenses/LICENSE_MATPLOTLIB), adapted for matplotlib_rs.
|
|
2
|
+
"""
|
|
3
|
+
2D lines with support for a variety of line styles, markers, colors, etc.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
import copy
|
|
7
|
+
|
|
8
|
+
from numbers import Integral, Number, Real
|
|
9
|
+
import logging
|
|
10
|
+
|
|
11
|
+
import numpy as np
|
|
12
|
+
|
|
13
|
+
import matplotlib_rs as mpl
|
|
14
|
+
from . import _api, cbook, colors as mcolors, _docstring
|
|
15
|
+
from .artist import Artist, allow_rasterization
|
|
16
|
+
from .cbook import (
|
|
17
|
+
_to_unmasked_float_array, ls_mapper, ls_mapper_r, STEP_LOOKUP_MAP)
|
|
18
|
+
from .markers import MarkerStyle
|
|
19
|
+
from .path import Path
|
|
20
|
+
from .transforms import Bbox, BboxTransformTo, TransformedPath
|
|
21
|
+
from ._enums import JoinStyle, CapStyle
|
|
22
|
+
|
|
23
|
+
# Imported here for backward compatibility, even though they don't
|
|
24
|
+
# really belong.
|
|
25
|
+
from . import _path
|
|
26
|
+
from . import _mplrs
|
|
27
|
+
from .artist import _rs_base_props
|
|
28
|
+
from .markers import ( # noqa
|
|
29
|
+
CARETLEFT, CARETRIGHT, CARETUP, CARETDOWN,
|
|
30
|
+
CARETLEFTBASE, CARETRIGHTBASE, CARETUPBASE, CARETDOWNBASE,
|
|
31
|
+
TICKLEFT, TICKRIGHT, TICKUP, TICKDOWN)
|
|
32
|
+
|
|
33
|
+
_log = logging.getLogger(__name__)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
_EMPTY = np.empty(0)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def _rs_marker_parts(marker):
|
|
40
|
+
"""Describe a MarkerStyle for the Rust renderer."""
|
|
41
|
+
path = marker.get_path()
|
|
42
|
+
tr = marker.get_transform().get_matrix()
|
|
43
|
+
alt = marker.get_alt_path()
|
|
44
|
+
if alt is not None:
|
|
45
|
+
at = marker.get_alt_transform().get_matrix()
|
|
46
|
+
alt_v = alt.vertices.tolist()
|
|
47
|
+
alt_c = None if alt.codes is None else alt.codes.tolist()
|
|
48
|
+
at = [at[0].tolist(), at[1].tolist()]
|
|
49
|
+
else:
|
|
50
|
+
alt_v = alt_c = at = None
|
|
51
|
+
snap = marker.get_snap_threshold()
|
|
52
|
+
return (path.vertices.tolist(), None if path.codes is None else path.codes.tolist(),
|
|
53
|
+
[tr[0].tolist(), tr[1].tolist()], alt_v, alt_c, at,
|
|
54
|
+
marker.get_joinstyle(), marker.get_capstyle(),
|
|
55
|
+
None if snap is None else float(snap), bool(marker.is_filled()),
|
|
56
|
+
marker.get_fillstyle(), cbook._str_equal(marker.get_marker(), ","))
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def _rs_color(c, special=("auto", "none")):
|
|
60
|
+
if isinstance(c, str) and c.lower() in special:
|
|
61
|
+
return c.lower()
|
|
62
|
+
return mcolors.to_rgba(c)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def _get_dash_pattern(style):
|
|
66
|
+
"""Convert linestyle to dash pattern."""
|
|
67
|
+
# go from short hand -> full strings
|
|
68
|
+
if isinstance(style, str):
|
|
69
|
+
style = ls_mapper.get(style, style)
|
|
70
|
+
# un-dashed styles
|
|
71
|
+
if style in ['solid', 'None', 'none', '', ' ']:
|
|
72
|
+
offset = 0
|
|
73
|
+
dashes = None
|
|
74
|
+
# dashed styles
|
|
75
|
+
elif style in ['dashed', 'dashdot', 'dotted']:
|
|
76
|
+
offset = 0
|
|
77
|
+
dashes = tuple(mpl.rcParams[f'lines.{style}_pattern'])
|
|
78
|
+
#
|
|
79
|
+
elif isinstance(style, tuple):
|
|
80
|
+
offset, dashes = style
|
|
81
|
+
if offset is None:
|
|
82
|
+
raise ValueError(f'Unrecognized linestyle: {style!r}')
|
|
83
|
+
else:
|
|
84
|
+
raise ValueError(f'Unrecognized linestyle: {style!r}')
|
|
85
|
+
|
|
86
|
+
# normalize offset to be positive and shorter than the dash cycle
|
|
87
|
+
if dashes is not None:
|
|
88
|
+
dsum = sum(dashes)
|
|
89
|
+
if dsum:
|
|
90
|
+
offset %= dsum
|
|
91
|
+
|
|
92
|
+
return offset, dashes
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def _get_dash_patterns(styles):
|
|
96
|
+
"""Convert linestyle or sequence of linestyles to list of dash patterns."""
|
|
97
|
+
try:
|
|
98
|
+
patterns = [_get_dash_pattern(styles)]
|
|
99
|
+
except ValueError:
|
|
100
|
+
try:
|
|
101
|
+
patterns = [_get_dash_pattern(x) for x in styles]
|
|
102
|
+
except ValueError as err:
|
|
103
|
+
emsg = f'Do not know how to convert {styles!r} to dashes'
|
|
104
|
+
raise ValueError(emsg) from err
|
|
105
|
+
|
|
106
|
+
return patterns
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def _get_inverse_dash_pattern(offset, dashes):
|
|
110
|
+
"""Return the inverse of the given dash pattern, for filling the gaps."""
|
|
111
|
+
# Define the inverse pattern by moving the last gap to the start of the
|
|
112
|
+
# sequence.
|
|
113
|
+
gaps = dashes[-1:] + dashes[:-1]
|
|
114
|
+
# Set the offset so that this new first segment is skipped
|
|
115
|
+
# (see backend_bases.GraphicsContextBase.set_dashes for offset definition).
|
|
116
|
+
offset_gaps = offset + dashes[-1]
|
|
117
|
+
|
|
118
|
+
return offset_gaps, gaps
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def _scale_dashes(offset, dashes, lw):
|
|
122
|
+
if not mpl.rcParams['lines.scale_dashes']:
|
|
123
|
+
return offset, dashes
|
|
124
|
+
scaled_offset = offset * lw
|
|
125
|
+
scaled_dashes = ([x * lw if x is not None else None for x in dashes]
|
|
126
|
+
if dashes is not None else None)
|
|
127
|
+
return scaled_offset, scaled_dashes
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def segment_hits(cx, cy, x, y, radius):
|
|
131
|
+
"""
|
|
132
|
+
Return the indices of the segments in the polyline with coordinates (*cx*,
|
|
133
|
+
*cy*) that are within a distance *radius* of the point (*x*, *y*).
|
|
134
|
+
"""
|
|
135
|
+
# Process single points specially
|
|
136
|
+
if len(x) <= 1:
|
|
137
|
+
res, = np.nonzero((cx - x) ** 2 + (cy - y) ** 2 <= radius ** 2)
|
|
138
|
+
return res
|
|
139
|
+
|
|
140
|
+
# We need to lop the last element off a lot.
|
|
141
|
+
xr, yr = x[:-1], y[:-1]
|
|
142
|
+
|
|
143
|
+
# Only look at line segments whose nearest point to C on the line
|
|
144
|
+
# lies within the segment.
|
|
145
|
+
dx, dy = x[1:] - xr, y[1:] - yr
|
|
146
|
+
Lnorm_sq = dx ** 2 + dy ** 2 # Possibly want to eliminate Lnorm==0
|
|
147
|
+
u = ((cx - xr) * dx + (cy - yr) * dy) / Lnorm_sq
|
|
148
|
+
candidates = (u >= 0) & (u <= 1)
|
|
149
|
+
|
|
150
|
+
# Note that there is a little area near one side of each point
|
|
151
|
+
# which will be near neither segment, and another which will
|
|
152
|
+
# be near both, depending on the angle of the lines. The
|
|
153
|
+
# following radius test eliminates these ambiguities.
|
|
154
|
+
point_hits = (cx - x) ** 2 + (cy - y) ** 2 <= radius ** 2
|
|
155
|
+
candidates = candidates & ~(point_hits[:-1] | point_hits[1:])
|
|
156
|
+
|
|
157
|
+
# For those candidates which remain, determine how far they lie away
|
|
158
|
+
# from the line.
|
|
159
|
+
px, py = xr + u * dx, yr + u * dy
|
|
160
|
+
line_hits = (cx - px) ** 2 + (cy - py) ** 2 <= radius ** 2
|
|
161
|
+
line_hits = line_hits & candidates
|
|
162
|
+
points, = point_hits.ravel().nonzero()
|
|
163
|
+
lines, = line_hits.ravel().nonzero()
|
|
164
|
+
return np.concatenate((points, lines))
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
def _mark_every_path(markevery, tpath, affine, ax):
|
|
168
|
+
"""
|
|
169
|
+
Helper function that sorts out how to deal the input
|
|
170
|
+
`markevery` and returns the points where markers should be drawn.
|
|
171
|
+
|
|
172
|
+
Takes in the `markevery` value and the line path and returns the
|
|
173
|
+
sub-sampled path.
|
|
174
|
+
"""
|
|
175
|
+
# pull out the two bits of data we want from the path
|
|
176
|
+
codes, verts = tpath.codes, tpath.vertices
|
|
177
|
+
|
|
178
|
+
def _slice_or_none(in_v, slc):
|
|
179
|
+
"""Helper function to cope with `codes` being an ndarray or `None`."""
|
|
180
|
+
if in_v is None:
|
|
181
|
+
return None
|
|
182
|
+
return in_v[slc]
|
|
183
|
+
|
|
184
|
+
# if just an int, assume starting at 0 and make a tuple
|
|
185
|
+
if isinstance(markevery, Integral):
|
|
186
|
+
markevery = (0, markevery)
|
|
187
|
+
# if just a float, assume starting at 0.0 and make a tuple
|
|
188
|
+
elif isinstance(markevery, Real):
|
|
189
|
+
markevery = (0.0, markevery)
|
|
190
|
+
|
|
191
|
+
if isinstance(markevery, tuple):
|
|
192
|
+
if len(markevery) != 2:
|
|
193
|
+
raise ValueError('`markevery` is a tuple but its len is not 2; '
|
|
194
|
+
f'markevery={markevery}')
|
|
195
|
+
start, step = markevery
|
|
196
|
+
# if step is an int, old behavior
|
|
197
|
+
if isinstance(step, Integral):
|
|
198
|
+
# tuple of 2 int is for backwards compatibility,
|
|
199
|
+
if not isinstance(start, Integral):
|
|
200
|
+
raise ValueError(
|
|
201
|
+
'`markevery` is a tuple with len 2 and second element is '
|
|
202
|
+
'an int, but the first element is not an int; '
|
|
203
|
+
f'markevery={markevery}')
|
|
204
|
+
# just return, we are done here
|
|
205
|
+
|
|
206
|
+
return Path(verts[slice(start, None, step)],
|
|
207
|
+
_slice_or_none(codes, slice(start, None, step)))
|
|
208
|
+
|
|
209
|
+
elif isinstance(step, Real):
|
|
210
|
+
if not isinstance(start, Real):
|
|
211
|
+
raise ValueError(
|
|
212
|
+
'`markevery` is a tuple with len 2 and second element is '
|
|
213
|
+
'a float, but the first element is not a float or an int; '
|
|
214
|
+
f'markevery={markevery}')
|
|
215
|
+
if ax is None:
|
|
216
|
+
raise ValueError(
|
|
217
|
+
"markevery is specified relative to the Axes size, but "
|
|
218
|
+
"the line does not have an Axes as parent")
|
|
219
|
+
|
|
220
|
+
# calc cumulative distance along path (in display coords):
|
|
221
|
+
fin = np.isfinite(verts).all(axis=1)
|
|
222
|
+
fverts = verts[fin]
|
|
223
|
+
disp_coords = affine.transform(fverts)
|
|
224
|
+
|
|
225
|
+
delta = np.empty((len(disp_coords), 2))
|
|
226
|
+
delta[0, :] = 0
|
|
227
|
+
delta[1:, :] = disp_coords[1:, :] - disp_coords[:-1, :]
|
|
228
|
+
delta = np.hypot(*delta.T).cumsum()
|
|
229
|
+
# calc distance between markers along path based on the Axes
|
|
230
|
+
# bounding box diagonal being a distance of unity:
|
|
231
|
+
(x0, y0), (x1, y1) = ax.transAxes.transform([[0, 0], [1, 1]])
|
|
232
|
+
scale = np.hypot(x1 - x0, y1 - y0)
|
|
233
|
+
marker_start = start * scale
|
|
234
|
+
marker_step = step * scale
|
|
235
|
+
if marker_step <= 0:
|
|
236
|
+
raise ValueError(
|
|
237
|
+
f"'markevery' step must be positive, but got {step!r}")
|
|
238
|
+
# A theoretical marker can select a vertex only if the marker
|
|
239
|
+
# immediately before or after that vertex selects it. Limit
|
|
240
|
+
# the candidates to those markers instead of materializing
|
|
241
|
+
# every marker position, which may be arbitrarily large when
|
|
242
|
+
# zoomed in far enough.
|
|
243
|
+
marker_delta = delta - np.remainder(delta - marker_start, marker_step)
|
|
244
|
+
marker_delta = np.union1d(marker_delta, marker_delta + marker_step)
|
|
245
|
+
marker_delta = marker_delta[
|
|
246
|
+
(marker_delta >= marker_start) & (marker_delta < delta[-1])]
|
|
247
|
+
|
|
248
|
+
# Find each candidate's closest actual data point without
|
|
249
|
+
# constructing a len(marker_delta) x len(delta) array.
|
|
250
|
+
right = np.searchsorted(delta, marker_delta, side="left")
|
|
251
|
+
left = np.maximum(right - 1, 0)
|
|
252
|
+
right = np.minimum(right, len(delta) - 1)
|
|
253
|
+
inds = np.where(
|
|
254
|
+
np.abs(delta[right] - marker_delta)
|
|
255
|
+
< np.abs(marker_delta - delta[left]),
|
|
256
|
+
right, left)
|
|
257
|
+
# If there are multiple vertices at a given distance, use the
|
|
258
|
+
# first one.
|
|
259
|
+
inds = np.searchsorted(delta, delta[inds], side="left")
|
|
260
|
+
inds = np.unique(inds)
|
|
261
|
+
# return, we are done here
|
|
262
|
+
return Path(fverts[inds], _slice_or_none(codes, inds))
|
|
263
|
+
else:
|
|
264
|
+
raise ValueError(
|
|
265
|
+
f"markevery={markevery!r} is a tuple with len 2, but its "
|
|
266
|
+
f"second element is not an int or a float")
|
|
267
|
+
|
|
268
|
+
elif isinstance(markevery, slice):
|
|
269
|
+
# mazol tov, it's already a slice, just return
|
|
270
|
+
return Path(verts[markevery], _slice_or_none(codes, markevery))
|
|
271
|
+
|
|
272
|
+
elif np.iterable(markevery):
|
|
273
|
+
# fancy indexing
|
|
274
|
+
try:
|
|
275
|
+
return Path(verts[markevery], _slice_or_none(codes, markevery))
|
|
276
|
+
except (ValueError, IndexError) as err:
|
|
277
|
+
raise ValueError(
|
|
278
|
+
f"markevery={markevery!r} is iterable but not a valid numpy "
|
|
279
|
+
f"fancy index") from err
|
|
280
|
+
else:
|
|
281
|
+
raise ValueError(f"markevery={markevery!r} is not a recognized value")
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
@_docstring.interpd
|
|
285
|
+
@_api.define_aliases({
|
|
286
|
+
"antialiased": ["aa"],
|
|
287
|
+
"color": ["c"],
|
|
288
|
+
"drawstyle": ["ds"],
|
|
289
|
+
"linestyle": ["ls"],
|
|
290
|
+
"linewidth": ["lw"],
|
|
291
|
+
"markeredgecolor": ["mec"],
|
|
292
|
+
"markeredgewidth": ["mew"],
|
|
293
|
+
"markerfacecolor": ["mfc"],
|
|
294
|
+
"markerfacecoloralt": ["mfcalt"],
|
|
295
|
+
"markersize": ["ms"],
|
|
296
|
+
})
|
|
297
|
+
class Line2D(Artist):
|
|
298
|
+
"""
|
|
299
|
+
A line - the line can have both a solid linestyle connecting all
|
|
300
|
+
the vertices, and a marker at each vertex. Additionally, the
|
|
301
|
+
drawing of the solid line is influenced by the drawstyle, e.g., one
|
|
302
|
+
can create "stepped" lines in various styles.
|
|
303
|
+
"""
|
|
304
|
+
|
|
305
|
+
lineStyles = _lineStyles = { # hidden names deprecated
|
|
306
|
+
'-': '_draw_solid',
|
|
307
|
+
'--': '_draw_dashed',
|
|
308
|
+
'-.': '_draw_dash_dot',
|
|
309
|
+
':': '_draw_dotted',
|
|
310
|
+
'None': '_draw_nothing',
|
|
311
|
+
' ': '_draw_nothing',
|
|
312
|
+
'': '_draw_nothing',
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
_drawStyles_l = {
|
|
316
|
+
'default': '_draw_lines',
|
|
317
|
+
'steps-mid': '_draw_steps_mid',
|
|
318
|
+
'steps-pre': '_draw_steps_pre',
|
|
319
|
+
'steps-post': '_draw_steps_post',
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
_drawStyles_s = {
|
|
323
|
+
'steps': '_draw_steps_pre',
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
# drawStyles should now be deprecated.
|
|
327
|
+
drawStyles = {**_drawStyles_l, **_drawStyles_s}
|
|
328
|
+
# Need a list ordered with long names first:
|
|
329
|
+
drawStyleKeys = [*_drawStyles_l, *_drawStyles_s]
|
|
330
|
+
|
|
331
|
+
# Referenced here to maintain API. These are defined in
|
|
332
|
+
# MarkerStyle
|
|
333
|
+
markers = MarkerStyle.markers
|
|
334
|
+
filled_markers = MarkerStyle.filled_markers
|
|
335
|
+
fillStyles = MarkerStyle.fillstyles
|
|
336
|
+
|
|
337
|
+
zorder = 2
|
|
338
|
+
|
|
339
|
+
_subslice_optim_min_size = 1000
|
|
340
|
+
|
|
341
|
+
def __str__(self):
|
|
342
|
+
if self._label != "":
|
|
343
|
+
return f"Line2D({self._label})"
|
|
344
|
+
elif self._x is None:
|
|
345
|
+
return "Line2D()"
|
|
346
|
+
elif len(self._x) > 3:
|
|
347
|
+
return "Line2D(({:g},{:g}),({:g},{:g}),...,({:g},{:g}))".format(
|
|
348
|
+
self._x[0], self._y[0],
|
|
349
|
+
self._x[1], self._y[1],
|
|
350
|
+
self._x[-1], self._y[-1])
|
|
351
|
+
else:
|
|
352
|
+
return "Line2D(%s)" % ",".join(
|
|
353
|
+
map("({:g},{:g})".format, self._x, self._y))
|
|
354
|
+
|
|
355
|
+
def __init__(self, xdata, ydata, *,
|
|
356
|
+
linewidth=None, # all Nones default to rc
|
|
357
|
+
linestyle=None,
|
|
358
|
+
color=None,
|
|
359
|
+
gapcolor=None,
|
|
360
|
+
marker=None,
|
|
361
|
+
markersize=None,
|
|
362
|
+
markeredgewidth=None,
|
|
363
|
+
markeredgecolor=None,
|
|
364
|
+
markerfacecolor=None,
|
|
365
|
+
markerfacecoloralt='none',
|
|
366
|
+
fillstyle=None,
|
|
367
|
+
antialiased=None,
|
|
368
|
+
dash_capstyle=None,
|
|
369
|
+
solid_capstyle=None,
|
|
370
|
+
dash_joinstyle=None,
|
|
371
|
+
solid_joinstyle=None,
|
|
372
|
+
pickradius=5,
|
|
373
|
+
drawstyle=None,
|
|
374
|
+
markevery=None,
|
|
375
|
+
**kwargs
|
|
376
|
+
):
|
|
377
|
+
"""
|
|
378
|
+
Create a `.Line2D` instance with *x* and *y* data in sequences of
|
|
379
|
+
*xdata*, *ydata*.
|
|
380
|
+
|
|
381
|
+
Additional keyword arguments are `.Line2D` properties:
|
|
382
|
+
|
|
383
|
+
%(Line2D:kwdoc)s
|
|
384
|
+
|
|
385
|
+
See :meth:`set_linestyle` for a description of the line styles,
|
|
386
|
+
:meth:`set_marker` for a description of the markers, and
|
|
387
|
+
:meth:`set_drawstyle` for a description of the draw styles.
|
|
388
|
+
|
|
389
|
+
"""
|
|
390
|
+
self._h = _mplrs.Line2D(_EMPTY, _EMPTY)
|
|
391
|
+
super().__init__()
|
|
392
|
+
|
|
393
|
+
# Convert sequences to NumPy arrays.
|
|
394
|
+
if not np.iterable(xdata):
|
|
395
|
+
raise RuntimeError('xdata must be a sequence')
|
|
396
|
+
if not np.iterable(ydata):
|
|
397
|
+
raise RuntimeError('ydata must be a sequence')
|
|
398
|
+
|
|
399
|
+
linewidth = mpl._val_or_rc(linewidth, 'lines.linewidth')
|
|
400
|
+
linestyle = mpl._val_or_rc(linestyle, 'lines.linestyle')
|
|
401
|
+
marker = mpl._val_or_rc(marker, 'lines.marker')
|
|
402
|
+
color = mpl._val_or_rc(color, 'lines.color')
|
|
403
|
+
markersize = mpl._val_or_rc(markersize, 'lines.markersize')
|
|
404
|
+
antialiased = mpl._val_or_rc(antialiased, 'lines.antialiased')
|
|
405
|
+
dash_capstyle = mpl._val_or_rc(dash_capstyle, 'lines.dash_capstyle')
|
|
406
|
+
dash_joinstyle = mpl._val_or_rc(dash_joinstyle, 'lines.dash_joinstyle')
|
|
407
|
+
solid_capstyle = mpl._val_or_rc(solid_capstyle, 'lines.solid_capstyle')
|
|
408
|
+
solid_joinstyle = mpl._val_or_rc(solid_joinstyle, 'lines.solid_joinstyle')
|
|
409
|
+
|
|
410
|
+
if drawstyle is None:
|
|
411
|
+
drawstyle = 'default'
|
|
412
|
+
|
|
413
|
+
self._dashcapstyle = None
|
|
414
|
+
self._dashjoinstyle = None
|
|
415
|
+
self._solidjoinstyle = None
|
|
416
|
+
self._solidcapstyle = None
|
|
417
|
+
self.set_dash_capstyle(dash_capstyle)
|
|
418
|
+
self.set_dash_joinstyle(dash_joinstyle)
|
|
419
|
+
self.set_solid_capstyle(solid_capstyle)
|
|
420
|
+
self.set_solid_joinstyle(solid_joinstyle)
|
|
421
|
+
|
|
422
|
+
self._linestyles = None
|
|
423
|
+
self._drawstyle = None
|
|
424
|
+
self._linewidth = linewidth
|
|
425
|
+
self._unscaled_dash_pattern = (0, None) # offset, dash
|
|
426
|
+
self._dash_pattern = (0, None) # offset, dash (scaled by linewidth)
|
|
427
|
+
|
|
428
|
+
self.set_linewidth(linewidth)
|
|
429
|
+
self.set_linestyle(linestyle)
|
|
430
|
+
self.set_drawstyle(drawstyle)
|
|
431
|
+
|
|
432
|
+
self._color = None
|
|
433
|
+
self.set_color(color)
|
|
434
|
+
if marker is None:
|
|
435
|
+
marker = 'none' # Default.
|
|
436
|
+
if not isinstance(marker, MarkerStyle):
|
|
437
|
+
self._marker = MarkerStyle(marker, fillstyle)
|
|
438
|
+
else:
|
|
439
|
+
self._marker = marker
|
|
440
|
+
|
|
441
|
+
self._gapcolor = None
|
|
442
|
+
self.set_gapcolor(gapcolor)
|
|
443
|
+
|
|
444
|
+
self._markevery = None
|
|
445
|
+
self._markersize = None
|
|
446
|
+
self._antialiased = None
|
|
447
|
+
|
|
448
|
+
self.set_markevery(markevery)
|
|
449
|
+
self.set_antialiased(antialiased)
|
|
450
|
+
self.set_markersize(markersize)
|
|
451
|
+
|
|
452
|
+
self._markeredgecolor = None
|
|
453
|
+
self._markeredgewidth = None
|
|
454
|
+
self._markerfacecolor = None
|
|
455
|
+
self._markerfacecoloralt = None
|
|
456
|
+
|
|
457
|
+
self.set_markerfacecolor(markerfacecolor) # Normalizes None to rc.
|
|
458
|
+
self.set_markerfacecoloralt(markerfacecoloralt)
|
|
459
|
+
self.set_markeredgecolor(markeredgecolor) # Normalizes None to rc.
|
|
460
|
+
self.set_markeredgewidth(markeredgewidth)
|
|
461
|
+
|
|
462
|
+
# update kwargs before updating data to give the caller a
|
|
463
|
+
# chance to init axes (and hence unit support)
|
|
464
|
+
self._internal_update(kwargs)
|
|
465
|
+
self.pickradius = pickradius
|
|
466
|
+
self.ind_offset = 0
|
|
467
|
+
if (isinstance(self._picker, Number) and
|
|
468
|
+
not isinstance(self._picker, bool)):
|
|
469
|
+
self._pickradius = self._picker
|
|
470
|
+
|
|
471
|
+
self._xorig = np.asarray([])
|
|
472
|
+
self._yorig = np.asarray([])
|
|
473
|
+
self._invalidx = True
|
|
474
|
+
self._invalidy = True
|
|
475
|
+
self._x = None
|
|
476
|
+
self._y = None
|
|
477
|
+
self._xy = None
|
|
478
|
+
self._path = None
|
|
479
|
+
self._transformed_path = None
|
|
480
|
+
self._subslice = False
|
|
481
|
+
self._x_filled = None # used in subslicing; only x is needed
|
|
482
|
+
|
|
483
|
+
self.set_data(xdata, ydata)
|
|
484
|
+
self.stale = True
|
|
485
|
+
|
|
486
|
+
def contains(self, mouseevent):
|
|
487
|
+
"""
|
|
488
|
+
Test whether *mouseevent* occurred on the line.
|
|
489
|
+
|
|
490
|
+
An event is deemed to have occurred "on" the line if it is less
|
|
491
|
+
than ``self.pickradius`` (default: 5 points) away from it. Use
|
|
492
|
+
`~.Line2D.get_pickradius` or `~.Line2D.set_pickradius` to get or set
|
|
493
|
+
the pick radius.
|
|
494
|
+
|
|
495
|
+
Parameters
|
|
496
|
+
----------
|
|
497
|
+
mouseevent : `~matplotlib.backend_bases.MouseEvent`
|
|
498
|
+
|
|
499
|
+
Returns
|
|
500
|
+
-------
|
|
501
|
+
contains : bool
|
|
502
|
+
Whether any values are within the radius.
|
|
503
|
+
details : dict
|
|
504
|
+
A dictionary ``{'ind': pointlist}``, where *pointlist* is a
|
|
505
|
+
list of points of the line that are within the pickradius around
|
|
506
|
+
the event position.
|
|
507
|
+
|
|
508
|
+
TODO: sort returned indices by distance
|
|
509
|
+
"""
|
|
510
|
+
if self._different_canvas(mouseevent):
|
|
511
|
+
return False, {}
|
|
512
|
+
|
|
513
|
+
# Make sure we have data to plot
|
|
514
|
+
if self._invalidy or self._invalidx:
|
|
515
|
+
self.recache()
|
|
516
|
+
if len(self._xy) == 0:
|
|
517
|
+
return False, {}
|
|
518
|
+
|
|
519
|
+
# Convert points to pixels
|
|
520
|
+
transformed_path = self._get_transformed_path()
|
|
521
|
+
path, affine = transformed_path.get_transformed_path_and_affine()
|
|
522
|
+
path = affine.transform_path(path)
|
|
523
|
+
xy = path.vertices
|
|
524
|
+
xt = xy[:, 0]
|
|
525
|
+
yt = xy[:, 1]
|
|
526
|
+
|
|
527
|
+
# Convert pick radius from points to pixels
|
|
528
|
+
fig = self.get_figure(root=True)
|
|
529
|
+
if fig is None:
|
|
530
|
+
_log.warning('no figure set when check if mouse is on line')
|
|
531
|
+
pixels = self._pickradius
|
|
532
|
+
else:
|
|
533
|
+
pixels = fig.dpi / 72. * self._pickradius
|
|
534
|
+
|
|
535
|
+
# The math involved in checking for containment (here and inside of
|
|
536
|
+
# segment_hits) assumes that it is OK to overflow, so temporarily set
|
|
537
|
+
# the error flags accordingly.
|
|
538
|
+
with np.errstate(all='ignore'):
|
|
539
|
+
# Check for collision
|
|
540
|
+
if self._linestyle in ['None', None]:
|
|
541
|
+
# If no line, return the nearby point(s)
|
|
542
|
+
ind, = np.nonzero(
|
|
543
|
+
(xt - mouseevent.x) ** 2 + (yt - mouseevent.y) ** 2
|
|
544
|
+
<= pixels ** 2)
|
|
545
|
+
else:
|
|
546
|
+
# If line, return the nearby segment(s)
|
|
547
|
+
ind = segment_hits(mouseevent.x, mouseevent.y, xt, yt, pixels)
|
|
548
|
+
if self._drawstyle.startswith("steps"):
|
|
549
|
+
ind //= 2
|
|
550
|
+
|
|
551
|
+
ind += self.ind_offset
|
|
552
|
+
|
|
553
|
+
# Return the point(s) within radius
|
|
554
|
+
return len(ind) > 0, dict(ind=ind)
|
|
555
|
+
|
|
556
|
+
def get_pickradius(self):
|
|
557
|
+
"""
|
|
558
|
+
Return the pick radius used for containment tests.
|
|
559
|
+
|
|
560
|
+
See `.contains` for more details.
|
|
561
|
+
"""
|
|
562
|
+
return self._pickradius
|
|
563
|
+
|
|
564
|
+
def set_pickradius(self, pickradius):
|
|
565
|
+
"""
|
|
566
|
+
Set the pick radius used for containment tests.
|
|
567
|
+
|
|
568
|
+
See `.contains` for more details.
|
|
569
|
+
|
|
570
|
+
Parameters
|
|
571
|
+
----------
|
|
572
|
+
pickradius : float
|
|
573
|
+
Pick radius, in points.
|
|
574
|
+
"""
|
|
575
|
+
if not isinstance(pickradius, Real) or pickradius < 0:
|
|
576
|
+
raise ValueError("pick radius should be a distance")
|
|
577
|
+
self._pickradius = pickradius
|
|
578
|
+
|
|
579
|
+
pickradius = property(get_pickradius, set_pickradius)
|
|
580
|
+
|
|
581
|
+
def get_fillstyle(self):
|
|
582
|
+
"""
|
|
583
|
+
Return the marker fill style.
|
|
584
|
+
|
|
585
|
+
See also `~.Line2D.set_fillstyle`.
|
|
586
|
+
"""
|
|
587
|
+
return self._marker.get_fillstyle()
|
|
588
|
+
|
|
589
|
+
def set_fillstyle(self, fs):
|
|
590
|
+
"""
|
|
591
|
+
Set the marker fill style.
|
|
592
|
+
|
|
593
|
+
Parameters
|
|
594
|
+
----------
|
|
595
|
+
fs : {'full', 'left', 'right', 'bottom', 'top', 'none'}
|
|
596
|
+
Possible values:
|
|
597
|
+
|
|
598
|
+
- 'full': Fill the whole marker with the *markerfacecolor*.
|
|
599
|
+
- 'left', 'right', 'bottom', 'top': Fill the marker half at
|
|
600
|
+
the given side with the *markerfacecolor*. The other
|
|
601
|
+
half of the marker is filled with *markerfacecoloralt*.
|
|
602
|
+
- 'none': No filling.
|
|
603
|
+
|
|
604
|
+
For examples see :ref:`marker_fill_styles`.
|
|
605
|
+
"""
|
|
606
|
+
self.set_marker(MarkerStyle(self._marker.get_marker(), fs))
|
|
607
|
+
self.stale = True
|
|
608
|
+
|
|
609
|
+
def set_markevery(self, every):
|
|
610
|
+
"""
|
|
611
|
+
Set the markevery property to subsample the plot when using markers.
|
|
612
|
+
|
|
613
|
+
e.g., if ``every=5``, every 5-th marker will be plotted.
|
|
614
|
+
|
|
615
|
+
Parameters
|
|
616
|
+
----------
|
|
617
|
+
every : None or int or (int, int) or slice or list[int] or float or \
|
|
618
|
+
(float, float) or list[bool]
|
|
619
|
+
Which markers to plot.
|
|
620
|
+
|
|
621
|
+
- ``every=None``: every point will be plotted.
|
|
622
|
+
- ``every=N``: every N-th marker will be plotted starting with
|
|
623
|
+
marker 0.
|
|
624
|
+
- ``every=(start, N)``: every N-th marker, starting at index
|
|
625
|
+
*start*, will be plotted.
|
|
626
|
+
- ``every=slice(start, end, N)``: every N-th marker, starting at
|
|
627
|
+
index *start*, up to but not including index *end*, will be
|
|
628
|
+
plotted.
|
|
629
|
+
- ``every=[i, j, m, ...]``: only markers at the given indices
|
|
630
|
+
will be plotted.
|
|
631
|
+
- ``every=[True, False, True, ...]``: only positions that are True
|
|
632
|
+
will be plotted. The list must have the same length as the data
|
|
633
|
+
points.
|
|
634
|
+
- ``every=0.1``, (i.e. a float): markers will be spaced at
|
|
635
|
+
approximately equal visual distances along the line; the distance
|
|
636
|
+
along the line between markers is determined by multiplying the
|
|
637
|
+
display-coordinate distance of the Axes bounding-box diagonal
|
|
638
|
+
by the value of *every*.
|
|
639
|
+
- ``every=(0.5, 0.1)`` (i.e. a length-2 tuple of float): similar
|
|
640
|
+
to ``every=0.1`` but the first marker will be offset along the
|
|
641
|
+
line by 0.5 multiplied by the
|
|
642
|
+
display-coordinate-diagonal-distance along the line.
|
|
643
|
+
|
|
644
|
+
For examples see
|
|
645
|
+
:doc:`/gallery/lines_bars_and_markers/markevery_demo`.
|
|
646
|
+
|
|
647
|
+
Notes
|
|
648
|
+
-----
|
|
649
|
+
Setting *markevery* will still only draw markers at actual data points.
|
|
650
|
+
While the float argument form aims for uniform visual spacing, it has
|
|
651
|
+
to coerce from the ideal spacing to the nearest available data point.
|
|
652
|
+
Depending on the number and distribution of data points, the result
|
|
653
|
+
may still not look evenly spaced.
|
|
654
|
+
|
|
655
|
+
When using a start offset to specify the first marker, the offset will
|
|
656
|
+
be from the first data point which may be different from the first
|
|
657
|
+
the visible data point if the plot is zoomed in.
|
|
658
|
+
|
|
659
|
+
If zooming in on a plot when using float arguments then the actual
|
|
660
|
+
data points that have markers will change because the distance between
|
|
661
|
+
markers is always determined from the display-coordinates
|
|
662
|
+
axes-bounding-box-diagonal regardless of the actual axes data limits.
|
|
663
|
+
|
|
664
|
+
"""
|
|
665
|
+
self._markevery = every
|
|
666
|
+
self.stale = True
|
|
667
|
+
|
|
668
|
+
def get_markevery(self):
|
|
669
|
+
"""
|
|
670
|
+
Return the markevery setting for marker subsampling.
|
|
671
|
+
|
|
672
|
+
See also `~.Line2D.set_markevery`.
|
|
673
|
+
"""
|
|
674
|
+
return self._markevery
|
|
675
|
+
|
|
676
|
+
def set_picker(self, p):
|
|
677
|
+
"""
|
|
678
|
+
Set the event picker details for the line.
|
|
679
|
+
|
|
680
|
+
Parameters
|
|
681
|
+
----------
|
|
682
|
+
p : float or callable[[Artist, Event], tuple[bool, dict]]
|
|
683
|
+
If a float, it is used as the pick radius in points.
|
|
684
|
+
"""
|
|
685
|
+
if not callable(p):
|
|
686
|
+
self.set_pickradius(p)
|
|
687
|
+
self._picker = p
|
|
688
|
+
|
|
689
|
+
def get_bbox(self):
|
|
690
|
+
"""Get the bounding box of this line."""
|
|
691
|
+
bbox = Bbox([[0, 0], [0, 0]])
|
|
692
|
+
bbox.update_from_data_xy(self.get_xydata())
|
|
693
|
+
return bbox
|
|
694
|
+
|
|
695
|
+
def get_window_extent(self, renderer=None):
|
|
696
|
+
bbox = Bbox([[0, 0], [0, 0]])
|
|
697
|
+
trans_data_to_xy = self.get_transform().transform
|
|
698
|
+
bbox.update_from_data_xy(trans_data_to_xy(self.get_xydata()),
|
|
699
|
+
ignore=True)
|
|
700
|
+
# correct for marker size, if any
|
|
701
|
+
if self._marker:
|
|
702
|
+
ms = (self._markersize / 72.0 * self.get_figure(root=True).dpi) * 0.5
|
|
703
|
+
bbox = bbox.padded(ms)
|
|
704
|
+
return bbox
|
|
705
|
+
|
|
706
|
+
def set_data(self, *args):
|
|
707
|
+
"""
|
|
708
|
+
Set the x and y data.
|
|
709
|
+
|
|
710
|
+
Parameters
|
|
711
|
+
----------
|
|
712
|
+
*args : (2, N) array or two 1D arrays
|
|
713
|
+
|
|
714
|
+
See Also
|
|
715
|
+
--------
|
|
716
|
+
set_xdata
|
|
717
|
+
set_ydata
|
|
718
|
+
"""
|
|
719
|
+
if len(args) == 1:
|
|
720
|
+
(x, y), = args
|
|
721
|
+
else:
|
|
722
|
+
x, y = args
|
|
723
|
+
|
|
724
|
+
self.set_xdata(x)
|
|
725
|
+
self.set_ydata(y)
|
|
726
|
+
|
|
727
|
+
def recache_always(self):
|
|
728
|
+
self.recache(always=True)
|
|
729
|
+
|
|
730
|
+
def recache(self, always=False):
|
|
731
|
+
if always or self._invalidx:
|
|
732
|
+
xconv = self.convert_xunits(self._xorig)
|
|
733
|
+
x = _to_unmasked_float_array(xconv).ravel()
|
|
734
|
+
else:
|
|
735
|
+
x = self._x
|
|
736
|
+
if always or self._invalidy:
|
|
737
|
+
yconv = self.convert_yunits(self._yorig)
|
|
738
|
+
y = _to_unmasked_float_array(yconv).ravel()
|
|
739
|
+
else:
|
|
740
|
+
y = self._y
|
|
741
|
+
|
|
742
|
+
self._xy = np.column_stack(np.broadcast_arrays(x, y)).astype(float)
|
|
743
|
+
self._x = self._xy[:, 0] # views of the x and y data
|
|
744
|
+
self._y = self._xy[:, 1]
|
|
745
|
+
|
|
746
|
+
self._subslice = False
|
|
747
|
+
if (self.axes
|
|
748
|
+
and len(x) > self._subslice_optim_min_size
|
|
749
|
+
and _path.is_sorted_and_has_non_nan(x)
|
|
750
|
+
and self.axes.name == 'rectilinear'
|
|
751
|
+
and self.axes.get_xscale() == 'linear'
|
|
752
|
+
and self._markevery is None
|
|
753
|
+
and self.get_clip_on()
|
|
754
|
+
and self.get_transform() == self.axes.transData):
|
|
755
|
+
self._subslice = True
|
|
756
|
+
nanmask = np.isnan(x)
|
|
757
|
+
if nanmask.any():
|
|
758
|
+
self._x_filled = self._x.copy()
|
|
759
|
+
indices = np.arange(len(x))
|
|
760
|
+
self._x_filled[nanmask] = np.interp(
|
|
761
|
+
indices[nanmask], indices[~nanmask], self._x[~nanmask])
|
|
762
|
+
else:
|
|
763
|
+
self._x_filled = self._x
|
|
764
|
+
|
|
765
|
+
if self._path is not None:
|
|
766
|
+
interpolation_steps = self._path._interpolation_steps
|
|
767
|
+
else:
|
|
768
|
+
interpolation_steps = 1
|
|
769
|
+
if self._drawstyle == 'default':
|
|
770
|
+
vertices = self._xy
|
|
771
|
+
else:
|
|
772
|
+
step_func = STEP_LOOKUP_MAP[self._drawstyle]
|
|
773
|
+
vertices = np.asarray(step_func(*self._xy.T)).T
|
|
774
|
+
self._path = Path(vertices, _interpolation_steps=interpolation_steps)
|
|
775
|
+
self._transformed_path = None
|
|
776
|
+
self._invalidx = False
|
|
777
|
+
self._invalidy = False
|
|
778
|
+
|
|
779
|
+
def _transform_path(self, subslice=None):
|
|
780
|
+
"""
|
|
781
|
+
Put a TransformedPath instance at self._transformed_path;
|
|
782
|
+
all invalidation of the transform is then handled by the
|
|
783
|
+
TransformedPath instance.
|
|
784
|
+
"""
|
|
785
|
+
# Masked arrays are now handled by the Path class itself
|
|
786
|
+
if subslice is not None:
|
|
787
|
+
if self._drawstyle == 'default':
|
|
788
|
+
vertices = self._xy[subslice]
|
|
789
|
+
else:
|
|
790
|
+
step_func = STEP_LOOKUP_MAP[self._drawstyle]
|
|
791
|
+
vertices = np.asarray(step_func(*self._xy[subslice, :].T)).T
|
|
792
|
+
_path = Path(vertices,
|
|
793
|
+
_interpolation_steps=self._path._interpolation_steps)
|
|
794
|
+
else:
|
|
795
|
+
_path = self._path
|
|
796
|
+
self._transformed_path = TransformedPath(_path, self.get_transform())
|
|
797
|
+
|
|
798
|
+
def _get_transformed_path(self):
|
|
799
|
+
"""Return this line's `~matplotlib.transforms.TransformedPath`."""
|
|
800
|
+
if self._transformed_path is None:
|
|
801
|
+
self._transform_path()
|
|
802
|
+
return self._transformed_path
|
|
803
|
+
|
|
804
|
+
def set_transform(self, t):
|
|
805
|
+
# docstring inherited
|
|
806
|
+
self._invalidx = True
|
|
807
|
+
self._invalidy = True
|
|
808
|
+
super().set_transform(t)
|
|
809
|
+
|
|
810
|
+
@allow_rasterization
|
|
811
|
+
def draw(self, renderer):
|
|
812
|
+
# docstring inherited
|
|
813
|
+
|
|
814
|
+
if not self.get_visible():
|
|
815
|
+
return
|
|
816
|
+
|
|
817
|
+
if self._invalidy or self._invalidx:
|
|
818
|
+
self.recache()
|
|
819
|
+
self.ind_offset = 0 # Needed for contains() method.
|
|
820
|
+
if self._subslice and self.axes:
|
|
821
|
+
x0, x1 = self.axes.get_xbound()
|
|
822
|
+
i0 = self._x_filled.searchsorted(x0, 'left')
|
|
823
|
+
i1 = self._x_filled.searchsorted(x1, 'right')
|
|
824
|
+
subslice = slice(max(i0 - 1, 0), i1 + 1)
|
|
825
|
+
self.ind_offset = subslice.start
|
|
826
|
+
self._transform_path(subslice)
|
|
827
|
+
else:
|
|
828
|
+
subslice = None
|
|
829
|
+
|
|
830
|
+
if self.get_path_effects():
|
|
831
|
+
from matplotlib_rs.patheffects import PathEffectRenderer
|
|
832
|
+
renderer = PathEffectRenderer(self.get_path_effects(), renderer)
|
|
833
|
+
|
|
834
|
+
renderer.open_group('line2d', self.get_gid())
|
|
835
|
+
if self._lineStyles[self._linestyle] != '_draw_nothing':
|
|
836
|
+
tpath, affine = (self._get_transformed_path()
|
|
837
|
+
.get_transformed_path_and_affine())
|
|
838
|
+
if len(tpath.vertices):
|
|
839
|
+
gc = renderer.new_gc()
|
|
840
|
+
self._set_gc_clip(gc)
|
|
841
|
+
gc.set_url(self.get_url())
|
|
842
|
+
|
|
843
|
+
gc.set_antialiased(self._antialiased)
|
|
844
|
+
gc.set_linewidth(self._linewidth)
|
|
845
|
+
|
|
846
|
+
if self.is_dashed():
|
|
847
|
+
cap = self._dashcapstyle
|
|
848
|
+
join = self._dashjoinstyle
|
|
849
|
+
else:
|
|
850
|
+
cap = self._solidcapstyle
|
|
851
|
+
join = self._solidjoinstyle
|
|
852
|
+
gc.set_joinstyle(join)
|
|
853
|
+
gc.set_capstyle(cap)
|
|
854
|
+
gc.set_snap(self.get_snap())
|
|
855
|
+
if self.get_sketch_params() is not None:
|
|
856
|
+
gc.set_sketch_params(*self.get_sketch_params())
|
|
857
|
+
|
|
858
|
+
# We first draw a path within the gaps if needed, but only for
|
|
859
|
+
# visible dashed lines; zero-width lines would otherwise yield
|
|
860
|
+
# all-zero dashes.
|
|
861
|
+
if (self._linewidth > 0 and self.is_dashed()
|
|
862
|
+
and self._gapcolor is not None):
|
|
863
|
+
lc_rgba = mcolors.to_rgba(self._gapcolor, self._alpha)
|
|
864
|
+
gc.set_foreground(lc_rgba, isRGBA=True)
|
|
865
|
+
|
|
866
|
+
offset_gaps, gaps = _get_inverse_dash_pattern(
|
|
867
|
+
*self._dash_pattern)
|
|
868
|
+
|
|
869
|
+
gc.set_dashes(offset_gaps, gaps)
|
|
870
|
+
renderer.draw_path(gc, tpath, affine.frozen())
|
|
871
|
+
|
|
872
|
+
lc_rgba = mcolors.to_rgba(self._color, self._alpha)
|
|
873
|
+
gc.set_foreground(lc_rgba, isRGBA=True)
|
|
874
|
+
|
|
875
|
+
if self._linewidth > 0:
|
|
876
|
+
gc.set_dashes(*self._dash_pattern)
|
|
877
|
+
else:
|
|
878
|
+
gc.set_dashes(0, None)
|
|
879
|
+
renderer.draw_path(gc, tpath, affine.frozen())
|
|
880
|
+
gc.restore()
|
|
881
|
+
|
|
882
|
+
if self._marker and self._markersize > 0:
|
|
883
|
+
gc = renderer.new_gc()
|
|
884
|
+
self._set_gc_clip(gc)
|
|
885
|
+
gc.set_url(self.get_url())
|
|
886
|
+
gc.set_linewidth(self._markeredgewidth)
|
|
887
|
+
gc.set_antialiased(self._antialiased)
|
|
888
|
+
|
|
889
|
+
ec_rgba = mcolors.to_rgba(
|
|
890
|
+
self.get_markeredgecolor(), self._alpha)
|
|
891
|
+
fc_rgba = mcolors.to_rgba(
|
|
892
|
+
self._get_markerfacecolor(), self._alpha)
|
|
893
|
+
fcalt_rgba = mcolors.to_rgba(
|
|
894
|
+
self._get_markerfacecolor(alt=True), self._alpha)
|
|
895
|
+
# If the edgecolor is "auto", it is set according to the *line*
|
|
896
|
+
# color but inherits the alpha value of the *face* color, if any.
|
|
897
|
+
if (cbook._str_equal(self._markeredgecolor, "auto")
|
|
898
|
+
and not cbook._str_lower_equal(
|
|
899
|
+
self.get_markerfacecolor(), "none")):
|
|
900
|
+
ec_rgba = ec_rgba[:3] + (fc_rgba[3],)
|
|
901
|
+
gc.set_foreground(ec_rgba, isRGBA=True)
|
|
902
|
+
if self.get_sketch_params() is not None:
|
|
903
|
+
scale, length, randomness = self.get_sketch_params()
|
|
904
|
+
gc.set_sketch_params(scale/2, length/2, 2*randomness)
|
|
905
|
+
|
|
906
|
+
marker = self._marker
|
|
907
|
+
|
|
908
|
+
# Markers *must* be drawn ignoring the drawstyle (but don't pay the
|
|
909
|
+
# recaching if drawstyle is already "default").
|
|
910
|
+
if self.get_drawstyle() != "default":
|
|
911
|
+
with cbook._setattr_cm(
|
|
912
|
+
self, _drawstyle="default", _transformed_path=None):
|
|
913
|
+
self.recache()
|
|
914
|
+
self._transform_path(subslice)
|
|
915
|
+
tpath, affine = (self._get_transformed_path()
|
|
916
|
+
.get_transformed_points_and_affine())
|
|
917
|
+
else:
|
|
918
|
+
tpath, affine = (self._get_transformed_path()
|
|
919
|
+
.get_transformed_points_and_affine())
|
|
920
|
+
|
|
921
|
+
if len(tpath.vertices):
|
|
922
|
+
# subsample the markers if markevery is not None
|
|
923
|
+
markevery = self.get_markevery()
|
|
924
|
+
if markevery is not None:
|
|
925
|
+
subsampled = _mark_every_path(
|
|
926
|
+
markevery, tpath, affine, self.axes)
|
|
927
|
+
else:
|
|
928
|
+
subsampled = tpath
|
|
929
|
+
|
|
930
|
+
snap = marker.get_snap_threshold()
|
|
931
|
+
if isinstance(snap, Real):
|
|
932
|
+
snap = renderer.points_to_pixels(self._markersize) >= snap
|
|
933
|
+
gc.set_snap(snap)
|
|
934
|
+
gc.set_joinstyle(marker.get_joinstyle())
|
|
935
|
+
gc.set_capstyle(marker.get_capstyle())
|
|
936
|
+
marker_path = marker.get_path()
|
|
937
|
+
marker_trans = marker.get_transform()
|
|
938
|
+
w = renderer.points_to_pixels(self._markersize)
|
|
939
|
+
|
|
940
|
+
if cbook._str_equal(marker.get_marker(), ","):
|
|
941
|
+
gc.set_linewidth(0)
|
|
942
|
+
else:
|
|
943
|
+
# Don't scale for pixels, and don't stroke them
|
|
944
|
+
marker_trans = marker_trans.scale(w)
|
|
945
|
+
renderer.draw_markers(gc, marker_path, marker_trans,
|
|
946
|
+
subsampled, affine.frozen(),
|
|
947
|
+
fc_rgba)
|
|
948
|
+
|
|
949
|
+
alt_marker_path = marker.get_alt_path()
|
|
950
|
+
if alt_marker_path:
|
|
951
|
+
alt_marker_trans = marker.get_alt_transform()
|
|
952
|
+
alt_marker_trans = alt_marker_trans.scale(w)
|
|
953
|
+
renderer.draw_markers(
|
|
954
|
+
gc, alt_marker_path, alt_marker_trans, subsampled,
|
|
955
|
+
affine.frozen(), fcalt_rgba)
|
|
956
|
+
|
|
957
|
+
gc.restore()
|
|
958
|
+
|
|
959
|
+
renderer.close_group('line2d')
|
|
960
|
+
self.stale = False
|
|
961
|
+
|
|
962
|
+
def _rs_props(self):
|
|
963
|
+
"""This line's state as a Rust `set_many` dict."""
|
|
964
|
+
d = _rs_base_props(self, {})
|
|
965
|
+
try:
|
|
966
|
+
x = self.convert_xunits(self._xorig)
|
|
967
|
+
y = self.convert_yunits(self._yorig)
|
|
968
|
+
except Exception:
|
|
969
|
+
x, y = self._xorig, self._yorig
|
|
970
|
+
d["xdata"] = np.ascontiguousarray(_to_unmasked_float_array(x).ravel(), dtype=float)
|
|
971
|
+
d["ydata"] = np.ascontiguousarray(_to_unmasked_float_array(y).ravel(), dtype=float)
|
|
972
|
+
d["linewidth"] = float(self._linewidth)
|
|
973
|
+
ls = self._linestyle
|
|
974
|
+
d["linestyle"] = ls if ls in ("-", "None") else (
|
|
975
|
+
float(self._unscaled_dash_pattern[0]), self._unscaled_dash_pattern[1])
|
|
976
|
+
d["color"] = _rs_color(self._color)
|
|
977
|
+
d["gapcolor"] = None if self._gapcolor is None else _rs_color(self._gapcolor)
|
|
978
|
+
d["marker_parts"] = _rs_marker_parts(self._marker)
|
|
979
|
+
d["markersize"] = float(self._markersize)
|
|
980
|
+
d["markeredgewidth"] = float(self._markeredgewidth)
|
|
981
|
+
d["markeredgecolor"] = _rs_color(self._markeredgecolor)
|
|
982
|
+
d["markerfacecolor"] = _rs_color(self._markerfacecolor)
|
|
983
|
+
d["markerfacecoloralt"] = _rs_color(self._markerfacecoloralt)
|
|
984
|
+
d["antialiased"] = bool(self._antialiased)
|
|
985
|
+
d["drawstyle"] = self._drawstyle if self._drawstyle != "steps" else "steps-pre"
|
|
986
|
+
d["markevery"] = _rs_markevery(self._markevery, len(d["xdata"]))
|
|
987
|
+
d["dash_capstyle"] = self._dashcapstyle.name
|
|
988
|
+
d["solid_capstyle"] = self._solidcapstyle.name
|
|
989
|
+
d["dash_joinstyle"] = self._dashjoinstyle.name
|
|
990
|
+
d["solid_joinstyle"] = self._solidjoinstyle.name
|
|
991
|
+
d["dash_pattern"] = (float(self._dash_pattern[0]),
|
|
992
|
+
None if self._dash_pattern[1] is None else [float(v) for v in self._dash_pattern[1]])
|
|
993
|
+
return d
|
|
994
|
+
|
|
995
|
+
def get_antialiased(self):
|
|
996
|
+
"""Return whether antialiased rendering is used."""
|
|
997
|
+
return self._antialiased
|
|
998
|
+
|
|
999
|
+
def get_color(self):
|
|
1000
|
+
"""
|
|
1001
|
+
Return the line color.
|
|
1002
|
+
|
|
1003
|
+
See also `~.Line2D.set_color`.
|
|
1004
|
+
"""
|
|
1005
|
+
return self._color
|
|
1006
|
+
|
|
1007
|
+
def get_drawstyle(self):
|
|
1008
|
+
"""
|
|
1009
|
+
Return the drawstyle.
|
|
1010
|
+
|
|
1011
|
+
See also `~.Line2D.set_drawstyle`.
|
|
1012
|
+
"""
|
|
1013
|
+
return self._drawstyle
|
|
1014
|
+
|
|
1015
|
+
def get_gapcolor(self):
|
|
1016
|
+
"""
|
|
1017
|
+
Return the line gapcolor.
|
|
1018
|
+
|
|
1019
|
+
See also `~.Line2D.set_gapcolor`.
|
|
1020
|
+
"""
|
|
1021
|
+
return self._gapcolor
|
|
1022
|
+
|
|
1023
|
+
def get_linestyle(self):
|
|
1024
|
+
"""
|
|
1025
|
+
Return the linestyle.
|
|
1026
|
+
|
|
1027
|
+
See also `~.Line2D.set_linestyle`.
|
|
1028
|
+
"""
|
|
1029
|
+
return self._linestyle
|
|
1030
|
+
|
|
1031
|
+
def get_linewidth(self):
|
|
1032
|
+
"""
|
|
1033
|
+
Return the linewidth in points.
|
|
1034
|
+
|
|
1035
|
+
See also `~.Line2D.set_linewidth`.
|
|
1036
|
+
"""
|
|
1037
|
+
return self._linewidth
|
|
1038
|
+
|
|
1039
|
+
def get_marker(self):
|
|
1040
|
+
"""
|
|
1041
|
+
Return the line marker.
|
|
1042
|
+
|
|
1043
|
+
See also `~.Line2D.set_marker`.
|
|
1044
|
+
"""
|
|
1045
|
+
return self._marker.get_marker()
|
|
1046
|
+
|
|
1047
|
+
def get_markeredgecolor(self):
|
|
1048
|
+
"""
|
|
1049
|
+
Return the marker edge color.
|
|
1050
|
+
|
|
1051
|
+
See also `~.Line2D.set_markeredgecolor`.
|
|
1052
|
+
"""
|
|
1053
|
+
mec = self._markeredgecolor
|
|
1054
|
+
if cbook._str_equal(mec, 'auto'):
|
|
1055
|
+
if mpl.rcParams['_internal.classic_mode']:
|
|
1056
|
+
if self._marker.get_marker() in ('.', ','):
|
|
1057
|
+
return self._color
|
|
1058
|
+
if (self._marker.is_filled()
|
|
1059
|
+
and self._marker.get_fillstyle() != 'none'):
|
|
1060
|
+
return 'k' # Bad hard-wired default...
|
|
1061
|
+
return self._color
|
|
1062
|
+
else:
|
|
1063
|
+
return mec
|
|
1064
|
+
|
|
1065
|
+
def get_markeredgewidth(self):
|
|
1066
|
+
"""
|
|
1067
|
+
Return the marker edge width in points.
|
|
1068
|
+
|
|
1069
|
+
See also `~.Line2D.set_markeredgewidth`.
|
|
1070
|
+
"""
|
|
1071
|
+
return self._markeredgewidth
|
|
1072
|
+
|
|
1073
|
+
def _get_markerfacecolor(self, alt=False):
|
|
1074
|
+
if self._marker.get_fillstyle() == 'none':
|
|
1075
|
+
return 'none'
|
|
1076
|
+
fc = self._markerfacecoloralt if alt else self._markerfacecolor
|
|
1077
|
+
if cbook._str_lower_equal(fc, 'auto'):
|
|
1078
|
+
return self._color
|
|
1079
|
+
else:
|
|
1080
|
+
return fc
|
|
1081
|
+
|
|
1082
|
+
def get_markerfacecolor(self):
|
|
1083
|
+
"""
|
|
1084
|
+
Return the marker face color.
|
|
1085
|
+
|
|
1086
|
+
See also `~.Line2D.set_markerfacecolor`.
|
|
1087
|
+
"""
|
|
1088
|
+
return self._get_markerfacecolor(alt=False)
|
|
1089
|
+
|
|
1090
|
+
def get_markerfacecoloralt(self):
|
|
1091
|
+
"""
|
|
1092
|
+
Return the alternate marker face color.
|
|
1093
|
+
|
|
1094
|
+
See also `~.Line2D.set_markerfacecoloralt`.
|
|
1095
|
+
"""
|
|
1096
|
+
return self._get_markerfacecolor(alt=True)
|
|
1097
|
+
|
|
1098
|
+
def get_markersize(self):
|
|
1099
|
+
"""
|
|
1100
|
+
Return the marker size in points.
|
|
1101
|
+
|
|
1102
|
+
See also `~.Line2D.set_markersize`.
|
|
1103
|
+
"""
|
|
1104
|
+
return self._markersize
|
|
1105
|
+
|
|
1106
|
+
def get_data(self, orig=True):
|
|
1107
|
+
"""
|
|
1108
|
+
Return the line data as an ``(xdata, ydata)`` pair.
|
|
1109
|
+
|
|
1110
|
+
If *orig* is *True*, return the original data.
|
|
1111
|
+
"""
|
|
1112
|
+
return self.get_xdata(orig=orig), self.get_ydata(orig=orig)
|
|
1113
|
+
|
|
1114
|
+
def get_xdata(self, orig=True):
|
|
1115
|
+
"""
|
|
1116
|
+
Return the xdata.
|
|
1117
|
+
|
|
1118
|
+
If *orig* is *True*, return the original data, else the
|
|
1119
|
+
processed data.
|
|
1120
|
+
"""
|
|
1121
|
+
if orig:
|
|
1122
|
+
return self._xorig
|
|
1123
|
+
if self._invalidx:
|
|
1124
|
+
self.recache()
|
|
1125
|
+
return self._x
|
|
1126
|
+
|
|
1127
|
+
def get_ydata(self, orig=True):
|
|
1128
|
+
"""
|
|
1129
|
+
Return the ydata.
|
|
1130
|
+
|
|
1131
|
+
If *orig* is *True*, return the original data, else the
|
|
1132
|
+
processed data.
|
|
1133
|
+
"""
|
|
1134
|
+
if orig:
|
|
1135
|
+
return self._yorig
|
|
1136
|
+
if self._invalidy:
|
|
1137
|
+
self.recache()
|
|
1138
|
+
return self._y
|
|
1139
|
+
|
|
1140
|
+
def get_path(self):
|
|
1141
|
+
"""Return the `~matplotlib.path.Path` associated with this line."""
|
|
1142
|
+
if self._invalidy or self._invalidx:
|
|
1143
|
+
self.recache()
|
|
1144
|
+
return self._path
|
|
1145
|
+
|
|
1146
|
+
def get_xydata(self):
|
|
1147
|
+
"""Return the *xy* data as a (N, 2) array."""
|
|
1148
|
+
if self._invalidy or self._invalidx:
|
|
1149
|
+
self.recache()
|
|
1150
|
+
return self._xy
|
|
1151
|
+
|
|
1152
|
+
def set_antialiased(self, b):
|
|
1153
|
+
"""
|
|
1154
|
+
Set whether to use antialiased rendering.
|
|
1155
|
+
|
|
1156
|
+
Parameters
|
|
1157
|
+
----------
|
|
1158
|
+
b : bool
|
|
1159
|
+
"""
|
|
1160
|
+
if self._antialiased != b:
|
|
1161
|
+
self.stale = True
|
|
1162
|
+
self._antialiased = b
|
|
1163
|
+
|
|
1164
|
+
def set_color(self, color):
|
|
1165
|
+
"""
|
|
1166
|
+
Set the color of the line.
|
|
1167
|
+
|
|
1168
|
+
Parameters
|
|
1169
|
+
----------
|
|
1170
|
+
color : :mpltype:`color`
|
|
1171
|
+
"""
|
|
1172
|
+
mcolors._check_color_like(color=color)
|
|
1173
|
+
self._color = color
|
|
1174
|
+
self.stale = True
|
|
1175
|
+
|
|
1176
|
+
def set_drawstyle(self, drawstyle):
|
|
1177
|
+
"""
|
|
1178
|
+
Set the drawstyle of the plot.
|
|
1179
|
+
|
|
1180
|
+
The drawstyle determines how the points are connected.
|
|
1181
|
+
|
|
1182
|
+
Parameters
|
|
1183
|
+
----------
|
|
1184
|
+
drawstyle : {'default', 'steps', 'steps-pre', 'steps-mid', \
|
|
1185
|
+
'steps-post'}, default: 'default'
|
|
1186
|
+
For 'default', the points are connected with straight lines.
|
|
1187
|
+
|
|
1188
|
+
The steps variants connect the points with step-like lines,
|
|
1189
|
+
i.e. horizontal lines with vertical steps. They differ in the
|
|
1190
|
+
location of the step:
|
|
1191
|
+
|
|
1192
|
+
- 'steps-pre': The step is at the beginning of the line segment,
|
|
1193
|
+
i.e. the line will be at the y-value of point to the right.
|
|
1194
|
+
- 'steps-mid': The step is halfway between the points.
|
|
1195
|
+
- 'steps-post: The step is at the end of the line segment,
|
|
1196
|
+
i.e. the line will be at the y-value of the point to the left.
|
|
1197
|
+
- 'steps' is equal to 'steps-pre' and is maintained for
|
|
1198
|
+
backward-compatibility.
|
|
1199
|
+
|
|
1200
|
+
For examples see :doc:`/gallery/lines_bars_and_markers/step_demo`.
|
|
1201
|
+
"""
|
|
1202
|
+
if drawstyle is None:
|
|
1203
|
+
drawstyle = 'default'
|
|
1204
|
+
_api.check_in_list(self.drawStyles, drawstyle=drawstyle)
|
|
1205
|
+
if self._drawstyle != drawstyle:
|
|
1206
|
+
self.stale = True
|
|
1207
|
+
# invalidate to trigger a recache of the path
|
|
1208
|
+
self._invalidx = True
|
|
1209
|
+
self._drawstyle = drawstyle
|
|
1210
|
+
|
|
1211
|
+
def set_gapcolor(self, gapcolor):
|
|
1212
|
+
"""
|
|
1213
|
+
Set a color to fill the gaps in the dashed line style.
|
|
1214
|
+
|
|
1215
|
+
.. note::
|
|
1216
|
+
|
|
1217
|
+
Striped lines are created by drawing two interleaved dashed lines.
|
|
1218
|
+
There can be overlaps between those two, which may result in
|
|
1219
|
+
artifacts when using transparency.
|
|
1220
|
+
|
|
1221
|
+
This functionality is experimental and may change.
|
|
1222
|
+
|
|
1223
|
+
Parameters
|
|
1224
|
+
----------
|
|
1225
|
+
gapcolor : :mpltype:`color` or None
|
|
1226
|
+
The color with which to fill the gaps. If None, the gaps are
|
|
1227
|
+
unfilled.
|
|
1228
|
+
"""
|
|
1229
|
+
if gapcolor is not None:
|
|
1230
|
+
mcolors._check_color_like(color=gapcolor)
|
|
1231
|
+
self._gapcolor = gapcolor
|
|
1232
|
+
self.stale = True
|
|
1233
|
+
|
|
1234
|
+
def set_linewidth(self, w):
|
|
1235
|
+
"""
|
|
1236
|
+
Set the line width in points.
|
|
1237
|
+
|
|
1238
|
+
Parameters
|
|
1239
|
+
----------
|
|
1240
|
+
w : float
|
|
1241
|
+
Line width, in points.
|
|
1242
|
+
"""
|
|
1243
|
+
w = float(w)
|
|
1244
|
+
if self._linewidth != w:
|
|
1245
|
+
self.stale = True
|
|
1246
|
+
self._linewidth = w
|
|
1247
|
+
self._dash_pattern = _scale_dashes(*self._unscaled_dash_pattern, w)
|
|
1248
|
+
|
|
1249
|
+
def set_linestyle(self, ls):
|
|
1250
|
+
"""
|
|
1251
|
+
Set the linestyle of the line.
|
|
1252
|
+
|
|
1253
|
+
Parameters
|
|
1254
|
+
----------
|
|
1255
|
+
ls : {'-', '--', '-.', ':', '', ...} or (offset, on-off-seq)
|
|
1256
|
+
Possible values:
|
|
1257
|
+
|
|
1258
|
+
- A string:
|
|
1259
|
+
|
|
1260
|
+
======================================================= ================
|
|
1261
|
+
linestyle description
|
|
1262
|
+
======================================================= ================
|
|
1263
|
+
``'-'`` or ``'solid'`` solid line
|
|
1264
|
+
``'--'`` or ``'dashed'`` dashed line
|
|
1265
|
+
``'-.'`` or ``'dashdot'`` dash-dotted line
|
|
1266
|
+
``':'`` or ``'dotted'`` dotted line
|
|
1267
|
+
``''`` or ``'none'`` (discouraged: ``'None'``, ``' '``) draw nothing
|
|
1268
|
+
======================================================= ================
|
|
1269
|
+
|
|
1270
|
+
- A tuple describing the start position and lengths of dashes and spaces:
|
|
1271
|
+
|
|
1272
|
+
(offset, onoffseq)
|
|
1273
|
+
|
|
1274
|
+
where
|
|
1275
|
+
|
|
1276
|
+
- *offset* is a float specifying the offset (in points); i.e. how much
|
|
1277
|
+
is the dash pattern shifted.
|
|
1278
|
+
- *onoffseq* is a sequence of on and off ink in points. There can be
|
|
1279
|
+
arbitrary many pairs of on and off values.
|
|
1280
|
+
|
|
1281
|
+
Example: The tuple ``(0, (10, 5, 1, 5))`` means that the pattern starts
|
|
1282
|
+
at the beginning of the line. It draws a 10 point long dash,
|
|
1283
|
+
then a 5 point long space, then a 1 point long dash, followed by a 5 point
|
|
1284
|
+
long space, and then the pattern repeats.
|
|
1285
|
+
|
|
1286
|
+
See also :meth:`set_dashes`.
|
|
1287
|
+
|
|
1288
|
+
For examples see :doc:`/gallery/lines_bars_and_markers/linestyles`.
|
|
1289
|
+
"""
|
|
1290
|
+
if isinstance(ls, str):
|
|
1291
|
+
if ls in [' ', '', 'none']:
|
|
1292
|
+
ls = 'None'
|
|
1293
|
+
_api.check_in_list([*self._lineStyles, *ls_mapper_r], ls=ls)
|
|
1294
|
+
if ls not in self._lineStyles:
|
|
1295
|
+
ls = ls_mapper_r[ls]
|
|
1296
|
+
self._linestyle = ls
|
|
1297
|
+
else:
|
|
1298
|
+
self._linestyle = '--'
|
|
1299
|
+
self._unscaled_dash_pattern = _get_dash_pattern(ls)
|
|
1300
|
+
self._dash_pattern = _scale_dashes(
|
|
1301
|
+
*self._unscaled_dash_pattern, self._linewidth)
|
|
1302
|
+
self.stale = True
|
|
1303
|
+
|
|
1304
|
+
@_docstring.interpd
|
|
1305
|
+
def set_marker(self, marker):
|
|
1306
|
+
"""
|
|
1307
|
+
Set the line marker.
|
|
1308
|
+
|
|
1309
|
+
Parameters
|
|
1310
|
+
----------
|
|
1311
|
+
marker : marker style string, `~.path.Path` or `~.markers.MarkerStyle`
|
|
1312
|
+
See `~matplotlib.markers` for full description of possible
|
|
1313
|
+
arguments.
|
|
1314
|
+
"""
|
|
1315
|
+
self._marker = MarkerStyle(marker, self._marker.get_fillstyle())
|
|
1316
|
+
self.stale = True
|
|
1317
|
+
|
|
1318
|
+
def _set_markercolor(self, name, has_rcdefault, val):
|
|
1319
|
+
if val is None:
|
|
1320
|
+
val = mpl.rcParams[f"lines.{name}"] if has_rcdefault else "auto"
|
|
1321
|
+
attr = f"_{name}"
|
|
1322
|
+
current = getattr(self, attr)
|
|
1323
|
+
if current is None:
|
|
1324
|
+
self.stale = True
|
|
1325
|
+
else:
|
|
1326
|
+
neq = current != val
|
|
1327
|
+
# Much faster than `np.any(current != val)` if no arrays are used.
|
|
1328
|
+
if neq.any() if isinstance(neq, np.ndarray) else neq:
|
|
1329
|
+
self.stale = True
|
|
1330
|
+
setattr(self, attr, val)
|
|
1331
|
+
|
|
1332
|
+
def set_markeredgecolor(self, ec):
|
|
1333
|
+
"""
|
|
1334
|
+
Set the marker edge color.
|
|
1335
|
+
|
|
1336
|
+
Parameters
|
|
1337
|
+
----------
|
|
1338
|
+
ec : :mpltype:`color`
|
|
1339
|
+
"""
|
|
1340
|
+
self._set_markercolor("markeredgecolor", True, ec)
|
|
1341
|
+
|
|
1342
|
+
def set_markerfacecolor(self, fc):
|
|
1343
|
+
"""
|
|
1344
|
+
Set the marker face color.
|
|
1345
|
+
|
|
1346
|
+
Parameters
|
|
1347
|
+
----------
|
|
1348
|
+
fc : :mpltype:`color`
|
|
1349
|
+
"""
|
|
1350
|
+
self._set_markercolor("markerfacecolor", True, fc)
|
|
1351
|
+
|
|
1352
|
+
def set_markerfacecoloralt(self, fc):
|
|
1353
|
+
"""
|
|
1354
|
+
Set the alternate marker face color.
|
|
1355
|
+
|
|
1356
|
+
Parameters
|
|
1357
|
+
----------
|
|
1358
|
+
fc : :mpltype:`color`
|
|
1359
|
+
"""
|
|
1360
|
+
self._set_markercolor("markerfacecoloralt", False, fc)
|
|
1361
|
+
|
|
1362
|
+
def set_markeredgewidth(self, ew):
|
|
1363
|
+
"""
|
|
1364
|
+
Set the marker edge width in points.
|
|
1365
|
+
|
|
1366
|
+
Parameters
|
|
1367
|
+
----------
|
|
1368
|
+
ew : float
|
|
1369
|
+
Marker edge width, in points.
|
|
1370
|
+
"""
|
|
1371
|
+
ew = mpl._val_or_rc(ew, 'lines.markeredgewidth')
|
|
1372
|
+
if self._markeredgewidth != ew:
|
|
1373
|
+
self.stale = True
|
|
1374
|
+
self._markeredgewidth = ew
|
|
1375
|
+
|
|
1376
|
+
def set_markersize(self, sz):
|
|
1377
|
+
"""
|
|
1378
|
+
Set the marker size in points.
|
|
1379
|
+
|
|
1380
|
+
Parameters
|
|
1381
|
+
----------
|
|
1382
|
+
sz : float
|
|
1383
|
+
Marker size, in points.
|
|
1384
|
+
"""
|
|
1385
|
+
sz = float(sz)
|
|
1386
|
+
if self._markersize != sz:
|
|
1387
|
+
self.stale = True
|
|
1388
|
+
self._markersize = sz
|
|
1389
|
+
|
|
1390
|
+
def set_xdata(self, x):
|
|
1391
|
+
"""
|
|
1392
|
+
Set the data array for x.
|
|
1393
|
+
|
|
1394
|
+
Parameters
|
|
1395
|
+
----------
|
|
1396
|
+
x : 1D array
|
|
1397
|
+
|
|
1398
|
+
See Also
|
|
1399
|
+
--------
|
|
1400
|
+
set_data
|
|
1401
|
+
set_ydata
|
|
1402
|
+
"""
|
|
1403
|
+
if not np.iterable(x):
|
|
1404
|
+
raise RuntimeError('x must be a sequence')
|
|
1405
|
+
self._xorig = copy.copy(x)
|
|
1406
|
+
self._invalidx = True
|
|
1407
|
+
self.stale = True
|
|
1408
|
+
|
|
1409
|
+
def set_ydata(self, y):
|
|
1410
|
+
"""
|
|
1411
|
+
Set the data array for y.
|
|
1412
|
+
|
|
1413
|
+
Parameters
|
|
1414
|
+
----------
|
|
1415
|
+
y : 1D array
|
|
1416
|
+
|
|
1417
|
+
See Also
|
|
1418
|
+
--------
|
|
1419
|
+
set_data
|
|
1420
|
+
set_xdata
|
|
1421
|
+
"""
|
|
1422
|
+
if not np.iterable(y):
|
|
1423
|
+
raise RuntimeError('y must be a sequence')
|
|
1424
|
+
self._yorig = copy.copy(y)
|
|
1425
|
+
self._invalidy = True
|
|
1426
|
+
self.stale = True
|
|
1427
|
+
|
|
1428
|
+
def set_dashes(self, seq):
|
|
1429
|
+
"""
|
|
1430
|
+
Set the dash sequence.
|
|
1431
|
+
|
|
1432
|
+
The dash sequence is a sequence of floats of even length describing
|
|
1433
|
+
the length of dashes and spaces in points.
|
|
1434
|
+
|
|
1435
|
+
For example, (5, 2, 1, 2) describes a sequence of 5 point and 1 point
|
|
1436
|
+
dashes separated by 2 point spaces.
|
|
1437
|
+
|
|
1438
|
+
See also `~.Line2D.set_gapcolor`, which allows those spaces to be
|
|
1439
|
+
filled with a color.
|
|
1440
|
+
|
|
1441
|
+
Parameters
|
|
1442
|
+
----------
|
|
1443
|
+
seq : sequence of floats (on/off ink in points) or (None, None)
|
|
1444
|
+
If *seq* is empty or ``(None, None)``, the linestyle will be set
|
|
1445
|
+
to solid.
|
|
1446
|
+
"""
|
|
1447
|
+
if seq == (None, None) or len(seq) == 0:
|
|
1448
|
+
self.set_linestyle('-')
|
|
1449
|
+
else:
|
|
1450
|
+
self.set_linestyle((0, seq))
|
|
1451
|
+
|
|
1452
|
+
def update_from(self, other):
|
|
1453
|
+
"""Copy properties from *other* to self."""
|
|
1454
|
+
super().update_from(other)
|
|
1455
|
+
self._linestyle = other._linestyle
|
|
1456
|
+
self._linewidth = other._linewidth
|
|
1457
|
+
self._color = other._color
|
|
1458
|
+
self._gapcolor = other._gapcolor
|
|
1459
|
+
self._markersize = other._markersize
|
|
1460
|
+
self._markerfacecolor = other._markerfacecolor
|
|
1461
|
+
self._markerfacecoloralt = other._markerfacecoloralt
|
|
1462
|
+
self._markeredgecolor = other._markeredgecolor
|
|
1463
|
+
self._markeredgewidth = other._markeredgewidth
|
|
1464
|
+
self._unscaled_dash_pattern = other._unscaled_dash_pattern
|
|
1465
|
+
self._dash_pattern = other._dash_pattern
|
|
1466
|
+
self._dashcapstyle = other._dashcapstyle
|
|
1467
|
+
self._dashjoinstyle = other._dashjoinstyle
|
|
1468
|
+
self._solidcapstyle = other._solidcapstyle
|
|
1469
|
+
self._solidjoinstyle = other._solidjoinstyle
|
|
1470
|
+
|
|
1471
|
+
self._marker = MarkerStyle(marker=other._marker)
|
|
1472
|
+
self._drawstyle = other._drawstyle
|
|
1473
|
+
|
|
1474
|
+
@_docstring.interpd
|
|
1475
|
+
def set_dash_joinstyle(self, s):
|
|
1476
|
+
"""
|
|
1477
|
+
How to join segments of the line if it `~Line2D.is_dashed`.
|
|
1478
|
+
|
|
1479
|
+
The default joinstyle is :rc:`lines.dash_joinstyle`.
|
|
1480
|
+
|
|
1481
|
+
Parameters
|
|
1482
|
+
----------
|
|
1483
|
+
s : `.JoinStyle` or %(JoinStyle)s
|
|
1484
|
+
"""
|
|
1485
|
+
js = JoinStyle(s)
|
|
1486
|
+
if self._dashjoinstyle != js:
|
|
1487
|
+
self.stale = True
|
|
1488
|
+
self._dashjoinstyle = js
|
|
1489
|
+
|
|
1490
|
+
@_docstring.interpd
|
|
1491
|
+
def set_solid_joinstyle(self, s):
|
|
1492
|
+
"""
|
|
1493
|
+
How to join segments if the line is solid (not `~Line2D.is_dashed`).
|
|
1494
|
+
|
|
1495
|
+
The default joinstyle is :rc:`lines.solid_joinstyle`.
|
|
1496
|
+
|
|
1497
|
+
Parameters
|
|
1498
|
+
----------
|
|
1499
|
+
s : `.JoinStyle` or %(JoinStyle)s
|
|
1500
|
+
"""
|
|
1501
|
+
js = JoinStyle(s)
|
|
1502
|
+
if self._solidjoinstyle != js:
|
|
1503
|
+
self.stale = True
|
|
1504
|
+
self._solidjoinstyle = js
|
|
1505
|
+
|
|
1506
|
+
def get_dash_joinstyle(self):
|
|
1507
|
+
"""
|
|
1508
|
+
Return the `.JoinStyle` for dashed lines.
|
|
1509
|
+
|
|
1510
|
+
See also `~.Line2D.set_dash_joinstyle`.
|
|
1511
|
+
"""
|
|
1512
|
+
return self._dashjoinstyle.name
|
|
1513
|
+
|
|
1514
|
+
def get_solid_joinstyle(self):
|
|
1515
|
+
"""
|
|
1516
|
+
Return the `.JoinStyle` for solid lines.
|
|
1517
|
+
|
|
1518
|
+
See also `~.Line2D.set_solid_joinstyle`.
|
|
1519
|
+
"""
|
|
1520
|
+
return self._solidjoinstyle.name
|
|
1521
|
+
|
|
1522
|
+
@_docstring.interpd
|
|
1523
|
+
def set_dash_capstyle(self, s):
|
|
1524
|
+
"""
|
|
1525
|
+
How to draw the end caps if the line is `~Line2D.is_dashed`.
|
|
1526
|
+
|
|
1527
|
+
The default capstyle is :rc:`lines.dash_capstyle`.
|
|
1528
|
+
|
|
1529
|
+
Parameters
|
|
1530
|
+
----------
|
|
1531
|
+
s : `.CapStyle` or %(CapStyle)s
|
|
1532
|
+
"""
|
|
1533
|
+
cs = CapStyle(s)
|
|
1534
|
+
if self._dashcapstyle != cs:
|
|
1535
|
+
self.stale = True
|
|
1536
|
+
self._dashcapstyle = cs
|
|
1537
|
+
|
|
1538
|
+
@_docstring.interpd
|
|
1539
|
+
def set_solid_capstyle(self, s):
|
|
1540
|
+
"""
|
|
1541
|
+
How to draw the end caps if the line is solid (not `~Line2D.is_dashed`)
|
|
1542
|
+
|
|
1543
|
+
The default capstyle is :rc:`lines.solid_capstyle`.
|
|
1544
|
+
|
|
1545
|
+
Parameters
|
|
1546
|
+
----------
|
|
1547
|
+
s : `.CapStyle` or %(CapStyle)s
|
|
1548
|
+
"""
|
|
1549
|
+
cs = CapStyle(s)
|
|
1550
|
+
if self._solidcapstyle != cs:
|
|
1551
|
+
self.stale = True
|
|
1552
|
+
self._solidcapstyle = cs
|
|
1553
|
+
|
|
1554
|
+
def get_dash_capstyle(self):
|
|
1555
|
+
"""
|
|
1556
|
+
Return the `.CapStyle` for dashed lines.
|
|
1557
|
+
|
|
1558
|
+
See also `~.Line2D.set_dash_capstyle`.
|
|
1559
|
+
"""
|
|
1560
|
+
return self._dashcapstyle.name
|
|
1561
|
+
|
|
1562
|
+
def get_solid_capstyle(self):
|
|
1563
|
+
"""
|
|
1564
|
+
Return the `.CapStyle` for solid lines.
|
|
1565
|
+
|
|
1566
|
+
See also `~.Line2D.set_solid_capstyle`.
|
|
1567
|
+
"""
|
|
1568
|
+
return self._solidcapstyle.name
|
|
1569
|
+
|
|
1570
|
+
def is_dashed(self):
|
|
1571
|
+
"""
|
|
1572
|
+
Return whether line has a dashed linestyle.
|
|
1573
|
+
|
|
1574
|
+
A custom linestyle is assumed to be dashed, we do not inspect the
|
|
1575
|
+
``onoffseq`` directly.
|
|
1576
|
+
|
|
1577
|
+
See also `~.Line2D.set_linestyle`.
|
|
1578
|
+
"""
|
|
1579
|
+
return self._linestyle in ('--', '-.', ':')
|
|
1580
|
+
|
|
1581
|
+
|
|
1582
|
+
class AxLine(Line2D):
|
|
1583
|
+
"""
|
|
1584
|
+
A helper class that implements `~.Axes.axline`, by recomputing the artist
|
|
1585
|
+
transform at draw time.
|
|
1586
|
+
"""
|
|
1587
|
+
|
|
1588
|
+
def __init__(self, xy1, xy2, slope, **kwargs):
|
|
1589
|
+
"""
|
|
1590
|
+
Parameters
|
|
1591
|
+
----------
|
|
1592
|
+
xy1 : (float, float)
|
|
1593
|
+
The first set of (x, y) coordinates for the line to pass through.
|
|
1594
|
+
xy2 : (float, float) or None
|
|
1595
|
+
The second set of (x, y) coordinates for the line to pass through.
|
|
1596
|
+
Both *xy2* and *slope* must be passed, but one of them must be None.
|
|
1597
|
+
slope : float or None
|
|
1598
|
+
The slope of the line. Both *xy2* and *slope* must be passed, but one of
|
|
1599
|
+
them must be None.
|
|
1600
|
+
"""
|
|
1601
|
+
super().__init__([0, 1], [0, 1], **kwargs)
|
|
1602
|
+
|
|
1603
|
+
if (xy2 is None and slope is None or
|
|
1604
|
+
xy2 is not None and slope is not None):
|
|
1605
|
+
raise TypeError(
|
|
1606
|
+
"Exactly one of 'xy2' and 'slope' must be given")
|
|
1607
|
+
|
|
1608
|
+
self._slope = slope
|
|
1609
|
+
self._xy1 = xy1
|
|
1610
|
+
self._xy2 = xy2
|
|
1611
|
+
|
|
1612
|
+
def get_transform(self):
|
|
1613
|
+
ax = self.axes
|
|
1614
|
+
points_transform = self._transform - ax.transData + ax.transScale
|
|
1615
|
+
|
|
1616
|
+
if self._xy2 is not None:
|
|
1617
|
+
# two points were given
|
|
1618
|
+
(x1, y1), (x2, y2) = \
|
|
1619
|
+
points_transform.transform([self._xy1, self._xy2])
|
|
1620
|
+
dx = x2 - x1
|
|
1621
|
+
dy = y2 - y1
|
|
1622
|
+
if dx == 0:
|
|
1623
|
+
if dy == 0:
|
|
1624
|
+
raise ValueError(
|
|
1625
|
+
f"Cannot draw a line through two identical points "
|
|
1626
|
+
f"(x={(x1, x2)}, y={(y1, y2)})")
|
|
1627
|
+
slope = np.inf
|
|
1628
|
+
else:
|
|
1629
|
+
slope = dy / dx
|
|
1630
|
+
else:
|
|
1631
|
+
# one point and a slope were given
|
|
1632
|
+
x1, y1 = points_transform.transform(self._xy1)
|
|
1633
|
+
slope = self._slope
|
|
1634
|
+
(vxlo, vylo), (vxhi, vyhi) = ax.transScale.transform(ax.viewLim)
|
|
1635
|
+
# General case: find intersections with view limits in either
|
|
1636
|
+
# direction, and draw between the middle two points.
|
|
1637
|
+
if slope == 0:
|
|
1638
|
+
start = vxlo, y1
|
|
1639
|
+
stop = vxhi, y1
|
|
1640
|
+
elif np.isinf(slope):
|
|
1641
|
+
start = x1, vylo
|
|
1642
|
+
stop = x1, vyhi
|
|
1643
|
+
else:
|
|
1644
|
+
_, start, stop, _ = sorted([
|
|
1645
|
+
(vxlo, y1 + (vxlo - x1) * slope),
|
|
1646
|
+
(vxhi, y1 + (vxhi - x1) * slope),
|
|
1647
|
+
(x1 + (vylo - y1) / slope, vylo),
|
|
1648
|
+
(x1 + (vyhi - y1) / slope, vyhi),
|
|
1649
|
+
])
|
|
1650
|
+
return (BboxTransformTo(Bbox([start, stop]))
|
|
1651
|
+
+ ax.transLimits + ax.transAxes)
|
|
1652
|
+
|
|
1653
|
+
def draw(self, renderer):
|
|
1654
|
+
self._transformed_path = None # Force regen.
|
|
1655
|
+
super().draw(renderer)
|
|
1656
|
+
|
|
1657
|
+
def get_xy1(self):
|
|
1658
|
+
"""Return the *xy1* value of the line."""
|
|
1659
|
+
return self._xy1
|
|
1660
|
+
|
|
1661
|
+
def get_xy2(self):
|
|
1662
|
+
"""Return the *xy2* value of the line."""
|
|
1663
|
+
return self._xy2
|
|
1664
|
+
|
|
1665
|
+
def get_slope(self):
|
|
1666
|
+
"""Return the *slope* value of the line."""
|
|
1667
|
+
return self._slope
|
|
1668
|
+
|
|
1669
|
+
def set_xy1(self, *args, **kwargs):
|
|
1670
|
+
"""
|
|
1671
|
+
Set the *xy1* value of the line.
|
|
1672
|
+
|
|
1673
|
+
Parameters
|
|
1674
|
+
----------
|
|
1675
|
+
xy1 : tuple[float, float]
|
|
1676
|
+
Points for the line to pass through.
|
|
1677
|
+
"""
|
|
1678
|
+
params = _api.select_matching_signature([
|
|
1679
|
+
lambda self, x, y: locals(), lambda self, xy1: locals(),
|
|
1680
|
+
], self, *args, **kwargs)
|
|
1681
|
+
if "x" in params:
|
|
1682
|
+
_api.warn_deprecated("3.10", message=(
|
|
1683
|
+
"Passing x and y separately to AxLine.set_xy1 is deprecated since "
|
|
1684
|
+
"%(since)s; pass them as a single tuple instead."))
|
|
1685
|
+
xy1 = params["x"], params["y"]
|
|
1686
|
+
else:
|
|
1687
|
+
xy1 = params["xy1"]
|
|
1688
|
+
self._xy1 = xy1
|
|
1689
|
+
|
|
1690
|
+
def set_xy2(self, *args, **kwargs):
|
|
1691
|
+
"""
|
|
1692
|
+
Set the *xy2* value of the line.
|
|
1693
|
+
|
|
1694
|
+
.. note::
|
|
1695
|
+
|
|
1696
|
+
You can only set *xy2* if the line was created using the *xy2*
|
|
1697
|
+
parameter. If the line was created using *slope*, please use
|
|
1698
|
+
`~.AxLine.set_slope`.
|
|
1699
|
+
|
|
1700
|
+
Parameters
|
|
1701
|
+
----------
|
|
1702
|
+
xy2 : tuple[float, float]
|
|
1703
|
+
Points for the line to pass through.
|
|
1704
|
+
"""
|
|
1705
|
+
if self._slope is None:
|
|
1706
|
+
params = _api.select_matching_signature([
|
|
1707
|
+
lambda self, x, y: locals(), lambda self, xy2: locals(),
|
|
1708
|
+
], self, *args, **kwargs)
|
|
1709
|
+
if "x" in params:
|
|
1710
|
+
_api.warn_deprecated("3.10", message=(
|
|
1711
|
+
"Passing x and y separately to AxLine.set_xy2 is deprecated since "
|
|
1712
|
+
"%(since)s; pass them as a single tuple instead."))
|
|
1713
|
+
xy2 = params["x"], params["y"]
|
|
1714
|
+
else:
|
|
1715
|
+
xy2 = params["xy2"]
|
|
1716
|
+
self._xy2 = xy2
|
|
1717
|
+
else:
|
|
1718
|
+
raise ValueError("Cannot set an 'xy2' value while 'slope' is set;"
|
|
1719
|
+
" they differ but their functionalities overlap")
|
|
1720
|
+
|
|
1721
|
+
def set_slope(self, slope):
|
|
1722
|
+
"""
|
|
1723
|
+
Set the *slope* value of the line.
|
|
1724
|
+
|
|
1725
|
+
.. note::
|
|
1726
|
+
|
|
1727
|
+
You can only set *slope* if the line was created using the *slope*
|
|
1728
|
+
parameter. If the line was created using *xy2*, please use
|
|
1729
|
+
`~.AxLine.set_xy2`.
|
|
1730
|
+
|
|
1731
|
+
Parameters
|
|
1732
|
+
----------
|
|
1733
|
+
slope : float
|
|
1734
|
+
The slope of the line.
|
|
1735
|
+
"""
|
|
1736
|
+
if self._xy2 is None:
|
|
1737
|
+
self._slope = slope
|
|
1738
|
+
else:
|
|
1739
|
+
raise ValueError("Cannot set a 'slope' value while 'xy2' is set;"
|
|
1740
|
+
" they differ but their functionalities overlap")
|
|
1741
|
+
|
|
1742
|
+
|
|
1743
|
+
class VertexSelector:
|
|
1744
|
+
"""
|
|
1745
|
+
Manage the callbacks to maintain a list of selected vertices for `.Line2D`.
|
|
1746
|
+
Derived classes should override the `process_selected` method to do
|
|
1747
|
+
something with the picks.
|
|
1748
|
+
|
|
1749
|
+
Here is an example which highlights the selected verts with red circles::
|
|
1750
|
+
|
|
1751
|
+
import numpy as np
|
|
1752
|
+
import matplotlib_rs.pyplot as plt
|
|
1753
|
+
import matplotlib_rs.lines as lines
|
|
1754
|
+
|
|
1755
|
+
class HighlightSelected(lines.VertexSelector):
|
|
1756
|
+
def __init__(self, line, fmt='ro', **kwargs):
|
|
1757
|
+
super().__init__(line)
|
|
1758
|
+
self.markers, = self.axes.plot([], [], fmt, **kwargs)
|
|
1759
|
+
|
|
1760
|
+
def process_selected(self, ind, xs, ys):
|
|
1761
|
+
self.markers.set_data(xs, ys)
|
|
1762
|
+
self.canvas.draw()
|
|
1763
|
+
|
|
1764
|
+
fig, ax = plt.subplots()
|
|
1765
|
+
x, y = np.random.rand(2, 30)
|
|
1766
|
+
line, = ax.plot(x, y, 'bs-', picker=5)
|
|
1767
|
+
|
|
1768
|
+
selector = HighlightSelected(line)
|
|
1769
|
+
plt.show()
|
|
1770
|
+
"""
|
|
1771
|
+
|
|
1772
|
+
def __init__(self, line):
|
|
1773
|
+
"""
|
|
1774
|
+
Parameters
|
|
1775
|
+
----------
|
|
1776
|
+
line : `~matplotlib.lines.Line2D`
|
|
1777
|
+
The line must already have been added to an `~.axes.Axes` and must
|
|
1778
|
+
have its picker property set.
|
|
1779
|
+
"""
|
|
1780
|
+
if line.axes is None:
|
|
1781
|
+
raise RuntimeError('You must first add the line to the Axes')
|
|
1782
|
+
if line.get_picker() is None:
|
|
1783
|
+
raise RuntimeError('You must first set the picker property '
|
|
1784
|
+
'of the line')
|
|
1785
|
+
self.axes = line.axes
|
|
1786
|
+
self.line = line
|
|
1787
|
+
self.cid = self.canvas.callbacks._connect_picklable(
|
|
1788
|
+
'pick_event', self.onpick)
|
|
1789
|
+
self.ind = set()
|
|
1790
|
+
|
|
1791
|
+
canvas = property(lambda self: self.axes.get_figure(root=True).canvas)
|
|
1792
|
+
|
|
1793
|
+
def process_selected(self, ind, xs, ys):
|
|
1794
|
+
"""
|
|
1795
|
+
Default "do nothing" implementation of the `process_selected` method.
|
|
1796
|
+
|
|
1797
|
+
Parameters
|
|
1798
|
+
----------
|
|
1799
|
+
ind : list of int
|
|
1800
|
+
The indices of the selected vertices.
|
|
1801
|
+
xs, ys : array-like
|
|
1802
|
+
The coordinates of the selected vertices.
|
|
1803
|
+
"""
|
|
1804
|
+
pass
|
|
1805
|
+
|
|
1806
|
+
def onpick(self, event):
|
|
1807
|
+
"""When the line is picked, update the set of selected indices."""
|
|
1808
|
+
if event.artist is not self.line:
|
|
1809
|
+
return
|
|
1810
|
+
self.ind ^= set(event.ind)
|
|
1811
|
+
ind = sorted(self.ind)
|
|
1812
|
+
xdata, ydata = self.line.get_data()
|
|
1813
|
+
self.process_selected(ind, xdata[ind], ydata[ind])
|
|
1814
|
+
|
|
1815
|
+
|
|
1816
|
+
def _rs_markevery(markevery, n):
|
|
1817
|
+
"""``markevery`` as the Rust core's spec (see `_mark_every_path`)."""
|
|
1818
|
+
if markevery is None:
|
|
1819
|
+
return None
|
|
1820
|
+
if isinstance(markevery, Integral):
|
|
1821
|
+
return ("every", 0, int(markevery))
|
|
1822
|
+
if isinstance(markevery, Real):
|
|
1823
|
+
return ("fraction", 0.0, float(markevery))
|
|
1824
|
+
if isinstance(markevery, tuple) and len(markevery) == 2:
|
|
1825
|
+
start, step = markevery
|
|
1826
|
+
if isinstance(step, Integral):
|
|
1827
|
+
return ("every", int(start), int(step))
|
|
1828
|
+
return ("fraction", float(start), float(step))
|
|
1829
|
+
idx = np.arange(n)[markevery]
|
|
1830
|
+
return ("indices", [int(i) for i in np.atleast_1d(idx)])
|
|
1831
|
+
|
|
1832
|
+
|
|
1833
|
+
_RS_NAMED_MARKERS = {
|
|
1834
|
+
"tickleft": 0, "tickright": 1, "tickup": 2, "tickdown": 3,
|
|
1835
|
+
"caretleft": 4, "caretright": 5, "caretup": 6, "caretdown": 7,
|
|
1836
|
+
"caretleftbase": 8, "caretrightbase": 9, "caretupbase": 10, "caretdownbase": 11,
|
|
1837
|
+
}
|
|
1838
|
+
|
|
1839
|
+
|
|
1840
|
+
from . import artist as _martist
|
|
1841
|
+
|
|
1842
|
+
|
|
1843
|
+
class _RsLine2D(_martist._RsOwned, _martist._RsOwnedTransformMixin, Line2D):
|
|
1844
|
+
"""A `Line2D` view of a line owned by the Rust model (tick/grid lines)."""
|
|
1845
|
+
|
|
1846
|
+
@classmethod
|
|
1847
|
+
def _rs_blank(cls):
|
|
1848
|
+
self = cls([], [])
|
|
1849
|
+
_martist._DIRTY.discard(self)
|
|
1850
|
+
return self
|
|
1851
|
+
|
|
1852
|
+
def _rs_read(self, g):
|
|
1853
|
+
axes, fig = _martist._rs_owner_axes_fig(self._rs_owner)
|
|
1854
|
+
if fig is not None and self.figure is None:
|
|
1855
|
+
self.set_figure(fig)
|
|
1856
|
+
if axes is not None:
|
|
1857
|
+
self.__dict__["_axes"] = axes
|
|
1858
|
+
self.set_data(np.asarray(g("xdata"), float), np.asarray(g("ydata"), float))
|
|
1859
|
+
self.set_linewidth(g("linewidth"))
|
|
1860
|
+
try:
|
|
1861
|
+
self.set_linestyle(g("linestyle"))
|
|
1862
|
+
except (ValueError, TypeError):
|
|
1863
|
+
pass
|
|
1864
|
+
self.set_color(g("color"))
|
|
1865
|
+
m = g("marker")
|
|
1866
|
+
fs = g("fillstyle")
|
|
1867
|
+
if m != "path":
|
|
1868
|
+
self._marker = MarkerStyle(_RS_NAMED_MARKERS.get(m, m), fs)
|
|
1869
|
+
self.set_markersize(g("markersize"))
|
|
1870
|
+
self.set_markeredgewidth(g("markeredgewidth"))
|
|
1871
|
+
self.set_markeredgecolor(g("markeredgecolor"))
|
|
1872
|
+
self.set_markerfacecolor(g("markerfacecolor"))
|
|
1873
|
+
self.set_markerfacecoloralt(g("markerfacecoloralt"))
|
|
1874
|
+
self.set_drawstyle(g("drawstyle"))
|
|
1875
|
+
self._antialiased = g("antialiased")
|
|
1876
|
+
self._visible = g("visible")
|
|
1877
|
+
self._alpha = g("alpha")
|
|
1878
|
+
self.zorder = g("zorder")
|
|
1879
|
+
self._label = g("label")
|
|
1880
|
+
self._clipon = g("clip_on")
|
|
1881
|
+
|
|
1882
|
+
|
|
1883
|
+
lineStyles = Line2D._lineStyles
|
|
1884
|
+
lineMarkers = MarkerStyle.markers
|
|
1885
|
+
drawStyles = Line2D.drawStyles
|
|
1886
|
+
fillStyles = MarkerStyle.fillstyles
|