matplotlib-rs 0.0.8__cp315-cp315-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- docs/releases/0.0.1.md +268 -0
- docs/releases/0.0.2.md +69 -0
- docs/releases/0.0.3.md +80 -0
- docs/releases/0.0.4.md +73 -0
- docs/releases/0.0.5.md +24 -0
- docs/releases/0.0.6.md +24 -0
- docs/releases/0.0.7.md +24 -0
- docs/releases/0.0.8.md +16 -0
- licenses/LICENSE_CONTOURPY +29 -0
- licenses/LICENSE_CYCLER +27 -0
- licenses/LICENSE_DATEUTIL +54 -0
- licenses/LICENSE_KIWISOLVER +71 -0
- licenses/LICENSE_LIBWEBP +56 -0
- licenses/LICENSE_MATPLOTLIB +1253 -0
- licenses/LICENSE_PYPARSING +20 -0
- licenses/LICENSE_QHULL +39 -0
- licenses/LICENSE_SIX +18 -0
- matplotlib_rs/__init__.py +1683 -0
- matplotlib_rs/__main__.py +27 -0
- matplotlib_rs/_afm.py +500 -0
- matplotlib_rs/_animation_data.py +263 -0
- matplotlib_rs/_api/__init__.py +495 -0
- matplotlib_rs/_api/deprecation.py +534 -0
- matplotlib_rs/_axis_py.py +2991 -0
- matplotlib_rs/_blocking_input.py +31 -0
- matplotlib_rs/_cm.py +1500 -0
- matplotlib_rs/_cm_bivar.py +1289 -0
- matplotlib_rs/_cm_listed.py +2848 -0
- matplotlib_rs/_cm_multivar.py +167 -0
- matplotlib_rs/_color_data.py +1142 -0
- matplotlib_rs/_colormap.py +132 -0
- matplotlib_rs/_constrained_layout.py +825 -0
- matplotlib_rs/_contour.py +108 -0
- matplotlib_rs/_doc_cache.py +12214 -0
- matplotlib_rs/_docstring.py +142 -0
- matplotlib_rs/_enums.py +178 -0
- matplotlib_rs/_figure_rs.py +294 -0
- matplotlib_rs/_fontconfig_pattern.py +129 -0
- matplotlib_rs/_foreign.py +220 -0
- matplotlib_rs/_hook.py +94 -0
- matplotlib_rs/_image.py +160 -0
- matplotlib_rs/_imageio.py +229 -0
- matplotlib_rs/_internal_utils.py +65 -0
- matplotlib_rs/_kiwi.py +484 -0
- matplotlib_rs/_layoutgrid.py +549 -0
- matplotlib_rs/_live.py +192 -0
- matplotlib_rs/_mathtext.py +3103 -0
- matplotlib_rs/_mathtext_data.py +1811 -0
- matplotlib_rs/_mplrs.cp315-win_amd64.pyd +0 -0
- matplotlib_rs/_path.py +25 -0
- matplotlib_rs/_png.py +162 -0
- matplotlib_rs/_pylab_helpers.py +137 -0
- matplotlib_rs/_qhull.py +66 -0
- matplotlib_rs/_rcpush.py +84 -0
- matplotlib_rs/_spines_rs.py +108 -0
- matplotlib_rs/_style_helpers.py +52 -0
- matplotlib_rs/_text_helpers.py +51 -0
- matplotlib_rs/_tight_bbox.py +85 -0
- matplotlib_rs/_tight_layout.py +302 -0
- matplotlib_rs/_tri.py +140 -0
- matplotlib_rs/_type1font.py +1228 -0
- matplotlib_rs/_vendor/__init__.py +8 -0
- matplotlib_rs/_vendor/cycler.py +574 -0
- matplotlib_rs/_vendor/dateutil/__init__.py +27 -0
- matplotlib_rs/_vendor/dateutil/_common.py +44 -0
- matplotlib_rs/_vendor/dateutil/_tzdata_impl.py +148 -0
- matplotlib_rs/_vendor/dateutil/_version.py +5 -0
- matplotlib_rs/_vendor/dateutil/easter.py +90 -0
- matplotlib_rs/_vendor/dateutil/parser/__init__.py +62 -0
- matplotlib_rs/_vendor/dateutil/parser/_parser.py +1614 -0
- matplotlib_rs/_vendor/dateutil/parser/isoparser.py +417 -0
- matplotlib_rs/_vendor/dateutil/relativedelta.py +597 -0
- matplotlib_rs/_vendor/dateutil/rrule.py +1765 -0
- matplotlib_rs/_vendor/dateutil/tz/__init__.py +61 -0
- matplotlib_rs/_vendor/dateutil/tz/_common.py +420 -0
- matplotlib_rs/_vendor/dateutil/tz/_factories.py +81 -0
- matplotlib_rs/_vendor/dateutil/tz/_tzfile.py +1429 -0
- matplotlib_rs/_vendor/dateutil/tz/_tzpath.py +105 -0
- matplotlib_rs/_vendor/dateutil/tz/tz.py +1473 -0
- matplotlib_rs/_vendor/dateutil/tz/win.py +371 -0
- matplotlib_rs/_vendor/dateutil/tzwin.py +3 -0
- matplotlib_rs/_vendor/dateutil/utils.py +72 -0
- matplotlib_rs/_vendor/dateutil/zoneinfo/__init__.py +234 -0
- matplotlib_rs/_vendor/pyparsing/__init__.py +414 -0
- matplotlib_rs/_vendor/pyparsing/actions.py +265 -0
- matplotlib_rs/_vendor/pyparsing/common.py +571 -0
- matplotlib_rs/_vendor/pyparsing/core.py +6973 -0
- matplotlib_rs/_vendor/pyparsing/exceptions.py +354 -0
- matplotlib_rs/_vendor/pyparsing/helpers.py +1770 -0
- matplotlib_rs/_vendor/pyparsing/results.py +929 -0
- matplotlib_rs/_vendor/pyparsing/testing.py +399 -0
- matplotlib_rs/_vendor/pyparsing/unicode.py +357 -0
- matplotlib_rs/_vendor/pyparsing/util.py +515 -0
- matplotlib_rs/_vendor/pyparsing/warnings.py +11 -0
- matplotlib_rs/_vendor/six.py +1004 -0
- matplotlib_rs/animation.py +1843 -0
- matplotlib_rs/artist.py +2302 -0
- matplotlib_rs/axes/__init__.py +19 -0
- matplotlib_rs/axes/_axes.py +9402 -0
- matplotlib_rs/axes/_bar.py +185 -0
- matplotlib_rs/axes/_base.py +5236 -0
- matplotlib_rs/axes/_base_rs.py +727 -0
- matplotlib_rs/axes/_boxplot.py +391 -0
- matplotlib_rs/axes/_hist.py +99 -0
- matplotlib_rs/axes/_secondary_axes.py +357 -0
- matplotlib_rs/axis.py +1963 -0
- matplotlib_rs/backend_bases.py +3760 -0
- matplotlib_rs/backend_managers.py +388 -0
- matplotlib_rs/backend_tools.py +1002 -0
- matplotlib_rs/backends/__init__.py +6 -0
- matplotlib_rs/backends/_backend_pdf_ps.py +451 -0
- matplotlib_rs/backends/backend_agg.py +552 -0
- matplotlib_rs/backends/backend_mixed.py +123 -0
- matplotlib_rs/backends/backend_pdf.py +2711 -0
- matplotlib_rs/backends/backend_pgf.py +1031 -0
- matplotlib_rs/backends/backend_ps.py +1491 -0
- matplotlib_rs/backends/backend_svg.py +1395 -0
- matplotlib_rs/backends/backend_template.py +214 -0
- matplotlib_rs/backends/registry.py +423 -0
- matplotlib_rs/bezier.py +691 -0
- matplotlib_rs/category.py +236 -0
- matplotlib_rs/cbook.py +2762 -0
- matplotlib_rs/cm.py +251 -0
- matplotlib_rs/collections.py +2711 -0
- matplotlib_rs/colorbar.py +1586 -0
- matplotlib_rs/colorizer.py +909 -0
- matplotlib_rs/colors.py +4278 -0
- matplotlib_rs/container.py +256 -0
- matplotlib_rs/contour.py +1756 -0
- matplotlib_rs/dates.py +1847 -0
- matplotlib_rs/dviread.py +1386 -0
- matplotlib_rs/figure.py +3815 -0
- matplotlib_rs/font_manager.py +1855 -0
- matplotlib_rs/ft2font.py +515 -0
- matplotlib_rs/gridspec.py +808 -0
- matplotlib_rs/hatch.py +244 -0
- matplotlib_rs/image.py +1863 -0
- matplotlib_rs/inset.py +291 -0
- matplotlib_rs/layout_engine.py +310 -0
- matplotlib_rs/legend.py +1480 -0
- matplotlib_rs/legend_handler.py +812 -0
- matplotlib_rs/lines.py +1886 -0
- matplotlib_rs/markers.py +908 -0
- matplotlib_rs/mathtext.py +141 -0
- matplotlib_rs/mlab.py +959 -0
- matplotlib_rs/mpl-data/fonts/ttf/DejaVuSans-Bold.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/DejaVuSans-BoldOblique.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/DejaVuSans-Oblique.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/DejaVuSans.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/DejaVuSansDisplay.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/DejaVuSansMono-Bold.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/DejaVuSansMono-BoldOblique.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/DejaVuSansMono-Oblique.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/DejaVuSansMono.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/DejaVuSerif-Bold.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/DejaVuSerif-BoldItalic.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/DejaVuSerif-Italic.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/DejaVuSerif.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/DejaVuSerifDisplay.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/LICENSE_DEJAVU +99 -0
- matplotlib_rs/mpl-data/fonts/ttf/LICENSE_STIX +124 -0
- matplotlib_rs/mpl-data/fonts/ttf/LastResortHE-Regular.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/STIXGeneral.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/STIXGeneralBol.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/STIXGeneralBolIta.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/STIXGeneralItalic.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/STIXNonUni.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/STIXNonUniBol.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/STIXNonUniBolIta.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/STIXNonUniIta.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/STIXSizFiveSymReg.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/STIXSizFourSymBol.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/STIXSizFourSymReg.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/STIXSizOneSymBol.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/STIXSizOneSymReg.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/STIXSizThreeSymBol.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/STIXSizThreeSymReg.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/STIXSizTwoSymBol.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/STIXSizTwoSymReg.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/cmb10.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/cmex10.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/cmmi10.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/cmr10.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/cmss10.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/cmsy10.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/cmti10.ttf +0 -0
- matplotlib_rs/mpl-data/fonts/ttf/cmtt10.ttf +0 -0
- matplotlib_rs/mpl-data/images/back-symbolic.svg +46 -0
- matplotlib_rs/mpl-data/images/back.pdf +0 -0
- matplotlib_rs/mpl-data/images/back.png +0 -0
- matplotlib_rs/mpl-data/images/back.svg +46 -0
- matplotlib_rs/mpl-data/images/back_large.png +0 -0
- matplotlib_rs/mpl-data/images/filesave-symbolic.svg +68 -0
- matplotlib_rs/mpl-data/images/filesave.pdf +72 -0
- matplotlib_rs/mpl-data/images/filesave.png +0 -0
- matplotlib_rs/mpl-data/images/filesave.svg +68 -0
- matplotlib_rs/mpl-data/images/filesave_large.png +0 -0
- matplotlib_rs/mpl-data/images/forward-symbolic.svg +46 -0
- matplotlib_rs/mpl-data/images/forward.pdf +0 -0
- matplotlib_rs/mpl-data/images/forward.png +0 -0
- matplotlib_rs/mpl-data/images/forward.svg +46 -0
- matplotlib_rs/mpl-data/images/forward_large.png +0 -0
- matplotlib_rs/mpl-data/images/hand.pdf +0 -0
- matplotlib_rs/mpl-data/images/hand.png +0 -0
- matplotlib_rs/mpl-data/images/hand.svg +130 -0
- matplotlib_rs/mpl-data/images/help-symbolic.svg +52 -0
- matplotlib_rs/mpl-data/images/help.pdf +71 -0
- matplotlib_rs/mpl-data/images/help.png +0 -0
- matplotlib_rs/mpl-data/images/help.svg +52 -0
- matplotlib_rs/mpl-data/images/help_large.png +0 -0
- matplotlib_rs/mpl-data/images/home-symbolic.svg +59 -0
- matplotlib_rs/mpl-data/images/home.pdf +0 -0
- matplotlib_rs/mpl-data/images/home.png +0 -0
- matplotlib_rs/mpl-data/images/home.svg +59 -0
- matplotlib_rs/mpl-data/images/home_large.png +0 -0
- matplotlib_rs/mpl-data/images/matplotlib.pdf +0 -0
- matplotlib_rs/mpl-data/images/matplotlib.png +0 -0
- matplotlib_rs/mpl-data/images/matplotlib.svg +3171 -0
- matplotlib_rs/mpl-data/images/matplotlib_large.png +0 -0
- matplotlib_rs/mpl-data/images/move-symbolic.svg +73 -0
- matplotlib_rs/mpl-data/images/move.pdf +0 -0
- matplotlib_rs/mpl-data/images/move.png +0 -0
- matplotlib_rs/mpl-data/images/move.svg +73 -0
- matplotlib_rs/mpl-data/images/move_large.png +0 -0
- matplotlib_rs/mpl-data/images/qt4_editor_options.pdf +0 -0
- matplotlib_rs/mpl-data/images/qt4_editor_options.png +0 -0
- matplotlib_rs/mpl-data/images/qt4_editor_options.svg +48 -0
- matplotlib_rs/mpl-data/images/qt4_editor_options_large.png +0 -0
- matplotlib_rs/mpl-data/images/subplots-symbolic.svg +81 -0
- matplotlib_rs/mpl-data/images/subplots.pdf +0 -0
- matplotlib_rs/mpl-data/images/subplots.png +0 -0
- matplotlib_rs/mpl-data/images/subplots.svg +81 -0
- matplotlib_rs/mpl-data/images/subplots_large.png +0 -0
- matplotlib_rs/mpl-data/images/zoom_to_rect-symbolic.svg +40 -0
- matplotlib_rs/mpl-data/images/zoom_to_rect.pdf +69 -0
- matplotlib_rs/mpl-data/images/zoom_to_rect.png +0 -0
- matplotlib_rs/mpl-data/images/zoom_to_rect.svg +40 -0
- matplotlib_rs/mpl-data/images/zoom_to_rect_large.png +0 -0
- matplotlib_rs/mpl-data/kpsewhich.lua +4 -0
- matplotlib_rs/mpl-data/matplotlibrc +849 -0
- matplotlib_rs/mpl-data/plot_directive/plot_directive.css +16 -0
- matplotlib_rs/mpl-data/sample_data/Minduka_Present_Blue_Pack.png +0 -0
- matplotlib_rs/mpl-data/sample_data/README.txt +2 -0
- matplotlib_rs/mpl-data/sample_data/Stocks.csv +526 -0
- matplotlib_rs/mpl-data/sample_data/axes_grid/bivariate_normal.npy +0 -0
- matplotlib_rs/mpl-data/sample_data/data_x_x2_x3.csv +11 -0
- matplotlib_rs/mpl-data/sample_data/eeg.dat +0 -0
- matplotlib_rs/mpl-data/sample_data/embedding_in_wx3.xrc +65 -0
- matplotlib_rs/mpl-data/sample_data/goog.npz +0 -0
- matplotlib_rs/mpl-data/sample_data/grace_hopper.jpg +0 -0
- matplotlib_rs/mpl-data/sample_data/jacksboro_fault_dem.npz +0 -0
- matplotlib_rs/mpl-data/sample_data/logo2.png +0 -0
- matplotlib_rs/mpl-data/sample_data/membrane.dat +0 -0
- matplotlib_rs/mpl-data/sample_data/msft.csv +66 -0
- matplotlib_rs/mpl-data/sample_data/s1045.ima.gz +0 -0
- matplotlib_rs/mpl-data/sample_data/topobathy.npz +0 -0
- matplotlib_rs/mpl-data/stylelib/Solarize_Light2.mplstyle +53 -0
- matplotlib_rs/mpl-data/stylelib/_classic_test_patch.mplstyle +8 -0
- matplotlib_rs/mpl-data/stylelib/_mpl-gallery-nogrid.mplstyle +19 -0
- matplotlib_rs/mpl-data/stylelib/_mpl-gallery.mplstyle +19 -0
- matplotlib_rs/mpl-data/stylelib/bmh.mplstyle +27 -0
- matplotlib_rs/mpl-data/stylelib/classic.mplstyle +491 -0
- matplotlib_rs/mpl-data/stylelib/dark_background.mplstyle +26 -0
- matplotlib_rs/mpl-data/stylelib/fast.mplstyle +11 -0
- matplotlib_rs/mpl-data/stylelib/fivethirtyeight.mplstyle +37 -0
- matplotlib_rs/mpl-data/stylelib/ggplot.mplstyle +39 -0
- matplotlib_rs/mpl-data/stylelib/grayscale.mplstyle +29 -0
- matplotlib_rs/mpl-data/stylelib/petroff10.mplstyle +5 -0
- matplotlib_rs/mpl-data/stylelib/petroff6.mplstyle +5 -0
- matplotlib_rs/mpl-data/stylelib/petroff8.mplstyle +5 -0
- matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-bright.mplstyle +3 -0
- matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-colorblind.mplstyle +3 -0
- matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-dark-palette.mplstyle +3 -0
- matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-dark.mplstyle +30 -0
- matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-darkgrid.mplstyle +30 -0
- matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-deep.mplstyle +3 -0
- matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-muted.mplstyle +3 -0
- matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-notebook.mplstyle +21 -0
- matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-paper.mplstyle +21 -0
- matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-pastel.mplstyle +3 -0
- matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-poster.mplstyle +21 -0
- matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-talk.mplstyle +21 -0
- matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-ticks.mplstyle +30 -0
- matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-white.mplstyle +30 -0
- matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-whitegrid.mplstyle +30 -0
- matplotlib_rs/mpl-data/stylelib/seaborn-v0_8.mplstyle +57 -0
- matplotlib_rs/mpl-data/stylelib/tableau-colorblind10.mplstyle +3 -0
- matplotlib_rs/mpl_toolkits/__init__.py +3 -0
- matplotlib_rs/mpl_toolkits/axes_grid1/__init__.py +11 -0
- matplotlib_rs/mpl_toolkits/axes_grid1/anchored_artists.py +415 -0
- matplotlib_rs/mpl_toolkits/axes_grid1/axes_divider.py +619 -0
- matplotlib_rs/mpl_toolkits/axes_grid1/axes_grid.py +565 -0
- matplotlib_rs/mpl_toolkits/axes_grid1/axes_rgb.py +158 -0
- matplotlib_rs/mpl_toolkits/axes_grid1/axes_size.py +272 -0
- matplotlib_rs/mpl_toolkits/axes_grid1/inset_locator.py +525 -0
- matplotlib_rs/mpl_toolkits/axes_grid1/mpl_axes.py +129 -0
- matplotlib_rs/mpl_toolkits/axes_grid1/parasite_axes.py +261 -0
- matplotlib_rs/mpl_toolkits/axisartist/__init__.py +15 -0
- matplotlib_rs/mpl_toolkits/axisartist/angle_helper.py +396 -0
- matplotlib_rs/mpl_toolkits/axisartist/axes_divider.py +3 -0
- matplotlib_rs/mpl_toolkits/axisartist/axis_artist.py +1148 -0
- matplotlib_rs/mpl_toolkits/axisartist/axisline_style.py +193 -0
- matplotlib_rs/mpl_toolkits/axisartist/axislines.py +475 -0
- matplotlib_rs/mpl_toolkits/axisartist/floating_axes.py +265 -0
- matplotlib_rs/mpl_toolkits/axisartist/grid_finder.py +329 -0
- matplotlib_rs/mpl_toolkits/axisartist/grid_helper_curvelinear.py +353 -0
- matplotlib_rs/mpl_toolkits/axisartist/parasite_axes.py +8 -0
- matplotlib_rs/mpl_toolkits/mplot3d/__init__.py +4 -0
- matplotlib_rs/mpl_toolkits/mplot3d/art3d.py +1758 -0
- matplotlib_rs/mpl_toolkits/mplot3d/axes3d.py +4462 -0
- matplotlib_rs/mpl_toolkits/mplot3d/axis3d.py +807 -0
- matplotlib_rs/mpl_toolkits/mplot3d/proj3d.py +270 -0
- matplotlib_rs/offsetbox.py +1726 -0
- matplotlib_rs/patches.py +5049 -0
- matplotlib_rs/path.py +1147 -0
- matplotlib_rs/patheffects.py +512 -0
- matplotlib_rs/projections/__init__.py +126 -0
- matplotlib_rs/projections/geo.py +512 -0
- matplotlib_rs/projections/polar.py +1518 -0
- matplotlib_rs/pylab.py +68 -0
- matplotlib_rs/pyplot.py +4834 -0
- matplotlib_rs/quiver.py +1236 -0
- matplotlib_rs/rcsetup.py +3435 -0
- matplotlib_rs/sankey.py +815 -0
- matplotlib_rs/scale.py +1002 -0
- matplotlib_rs/spines.py +618 -0
- matplotlib_rs/stackplot.py +144 -0
- matplotlib_rs/streamplot.py +768 -0
- matplotlib_rs/style/__init__.py +269 -0
- matplotlib_rs/style/core.py +28 -0
- matplotlib_rs/table.py +860 -0
- matplotlib_rs/texmanager.py +375 -0
- matplotlib_rs/text.py +2412 -0
- matplotlib_rs/textpath.py +377 -0
- matplotlib_rs/ticker.py +3111 -0
- matplotlib_rs/transforms.py +3069 -0
- matplotlib_rs/tri/__init__.py +24 -0
- matplotlib_rs/tri/_triangulation.py +248 -0
- matplotlib_rs/tri/_tricontour.py +271 -0
- matplotlib_rs/tri/_trifinder.py +97 -0
- matplotlib_rs/tri/_triinterpolate.py +1575 -0
- matplotlib_rs/tri/_tripcolor.py +170 -0
- matplotlib_rs/tri/_triplot.py +87 -0
- matplotlib_rs/tri/_trirefine.py +308 -0
- matplotlib_rs/tri/_tritools.py +264 -0
- matplotlib_rs/typing.py +597 -0
- matplotlib_rs/units.py +196 -0
- matplotlib_rs/widgets.py +4455 -0
- matplotlib_rs-0.0.8.dist-info/METADATA +392 -0
- matplotlib_rs-0.0.8.dist-info/RECORD +352 -0
- matplotlib_rs-0.0.8.dist-info/WHEEL +4 -0
- matplotlib_rs-0.0.8.dist-info/sboms/matplotlib-rs.cyclonedx.json +4390 -0
|
@@ -0,0 +1,768 @@
|
|
|
1
|
+
# Vendored from matplotlib 3.11 (see licenses/LICENSE_MATPLOTLIB), adapted for matplotlib_rs.
|
|
2
|
+
"""
|
|
3
|
+
Streamline plotting for 2D vector fields.
|
|
4
|
+
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import numpy as np
|
|
8
|
+
|
|
9
|
+
import matplotlib_rs as mpl
|
|
10
|
+
from matplotlib_rs import _api, colorizer, patches
|
|
11
|
+
import matplotlib_rs.colors as mcolors
|
|
12
|
+
import matplotlib_rs.collections as mcollections
|
|
13
|
+
import matplotlib_rs.lines as mlines
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
__all__ = ['streamplot']
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def streamplot(axes, x, y, u, v, density=1, linewidth=None, color=None,
|
|
20
|
+
cmap=None, norm=None, arrowsize=1, arrowstyle='-|>',
|
|
21
|
+
minlength=0.1, transform=None, zorder=None, start_points=None,
|
|
22
|
+
maxlength=4.0, integration_direction='both',
|
|
23
|
+
broken_streamlines=True, *, integration_max_step_scale=1.0,
|
|
24
|
+
integration_max_error_scale=1.0, num_arrows=1):
|
|
25
|
+
"""
|
|
26
|
+
Draw streamlines of a vector flow.
|
|
27
|
+
|
|
28
|
+
Parameters
|
|
29
|
+
----------
|
|
30
|
+
x, y : 1D/2D arrays
|
|
31
|
+
Evenly spaced strictly increasing arrays to make a grid. If 2D, all
|
|
32
|
+
rows of *x* must be equal and all columns of *y* must be equal; i.e.,
|
|
33
|
+
they must be as if generated by ``np.meshgrid(x_1d, y_1d)``.
|
|
34
|
+
u, v : 2D arrays
|
|
35
|
+
*x* and *y*-velocities. The number of rows and columns must match
|
|
36
|
+
the length of *y* and *x*, respectively.
|
|
37
|
+
density : float or (float, float)
|
|
38
|
+
Controls the closeness of streamlines. When ``density = 1``, the domain
|
|
39
|
+
is divided into a 30x30 grid. *density* linearly scales this grid.
|
|
40
|
+
Each cell in the grid can have, at most, one traversing streamline.
|
|
41
|
+
For different densities in each direction, use a tuple
|
|
42
|
+
(density_x, density_y).
|
|
43
|
+
linewidth : float or 2D array
|
|
44
|
+
The width of the streamlines. With a 2D array the line width can be
|
|
45
|
+
varied across the grid. The array must have the same shape as *u*
|
|
46
|
+
and *v*.
|
|
47
|
+
color : :mpltype:`color` or 2D array
|
|
48
|
+
The streamline color. If given an array, its values are converted to
|
|
49
|
+
colors using *cmap* and *norm*. The array must have the same shape
|
|
50
|
+
as *u* and *v*.
|
|
51
|
+
cmap, norm
|
|
52
|
+
Data normalization and colormapping parameters for *color*; only used
|
|
53
|
+
if *color* is an array of floats. See `~.Axes.imshow` for a detailed
|
|
54
|
+
description.
|
|
55
|
+
arrowsize : float
|
|
56
|
+
Scaling factor for the arrow size.
|
|
57
|
+
arrowstyle : str
|
|
58
|
+
Arrow style specification.
|
|
59
|
+
See `~matplotlib.patches.FancyArrowPatch`.
|
|
60
|
+
minlength : float
|
|
61
|
+
Minimum length of streamline in axes coordinates.
|
|
62
|
+
start_points : (N, 2) array
|
|
63
|
+
Coordinates of starting points for the streamlines in data coordinates
|
|
64
|
+
(the same coordinates as the *x* and *y* arrays).
|
|
65
|
+
zorder : float
|
|
66
|
+
The zorder of the streamlines and arrows.
|
|
67
|
+
Artists with lower zorder values are drawn first.
|
|
68
|
+
maxlength : float
|
|
69
|
+
Maximum length of streamline in axes coordinates.
|
|
70
|
+
integration_direction : {'forward', 'backward', 'both'}, default: 'both'
|
|
71
|
+
Integrate the streamline in forward, backward or both directions.
|
|
72
|
+
data : indexable object, optional
|
|
73
|
+
DATA_PARAMETER_PLACEHOLDER
|
|
74
|
+
broken_streamlines : boolean, default: True
|
|
75
|
+
If False, forces streamlines to continue until they
|
|
76
|
+
leave the plot domain. If True, they may be terminated if they
|
|
77
|
+
come too close to another streamline.
|
|
78
|
+
integration_max_step_scale : float, default: 1.0
|
|
79
|
+
Multiplier on the maximum allowable step in the streamline integration routine.
|
|
80
|
+
A value between zero and one results in a max integration step smaller than
|
|
81
|
+
the default max step, resulting in more accurate streamlines at the cost
|
|
82
|
+
of greater computation time; a value greater than one does the converse. Must be
|
|
83
|
+
greater than zero.
|
|
84
|
+
|
|
85
|
+
.. versionadded:: 3.11
|
|
86
|
+
|
|
87
|
+
integration_max_error_scale : float, default: 1.0
|
|
88
|
+
Multiplier on the maximum allowable error in the streamline integration routine.
|
|
89
|
+
A value between zero and one results in a tighter max integration error than
|
|
90
|
+
the default max error, resulting in more accurate streamlines at the cost
|
|
91
|
+
of greater computation time; a value greater than one does the converse. Must be
|
|
92
|
+
greater than zero.
|
|
93
|
+
|
|
94
|
+
.. versionadded:: 3.11
|
|
95
|
+
|
|
96
|
+
num_arrows : int
|
|
97
|
+
Number of arrows per streamline. The arrows are spaced equally along the steps
|
|
98
|
+
each streamline takes. Note that this can be different to being spaced equally
|
|
99
|
+
along the distance of the streamline.
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
Returns
|
|
103
|
+
-------
|
|
104
|
+
StreamplotSet
|
|
105
|
+
Container object with attributes
|
|
106
|
+
|
|
107
|
+
- ``lines``: `.LineCollection` of streamlines
|
|
108
|
+
|
|
109
|
+
- ``arrows``: `.PatchCollection` containing `.FancyArrowPatch`
|
|
110
|
+
objects representing the arrows half-way along streamlines.
|
|
111
|
+
|
|
112
|
+
This container will probably change in the future to allow changes
|
|
113
|
+
to the colormap, alpha, etc. for both lines and arrows, but these
|
|
114
|
+
changes should be backward compatible.
|
|
115
|
+
"""
|
|
116
|
+
grid = Grid(x, y)
|
|
117
|
+
mask = StreamMask(density)
|
|
118
|
+
dmap = DomainMap(grid, mask)
|
|
119
|
+
|
|
120
|
+
if integration_max_step_scale <= 0.0:
|
|
121
|
+
raise ValueError(
|
|
122
|
+
"The value of integration_max_step_scale must be > 0, " +
|
|
123
|
+
f"got {integration_max_step_scale}"
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
if integration_max_error_scale <= 0.0:
|
|
127
|
+
raise ValueError(
|
|
128
|
+
"The value of integration_max_error_scale must be > 0, " +
|
|
129
|
+
f"got {integration_max_error_scale}"
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
if num_arrows < 0:
|
|
133
|
+
raise ValueError(f"The value of num_arrows must be >= 0, got {num_arrows=}")
|
|
134
|
+
|
|
135
|
+
if zorder is None:
|
|
136
|
+
zorder = mlines.Line2D.zorder
|
|
137
|
+
|
|
138
|
+
# default to data coordinates
|
|
139
|
+
if transform is None:
|
|
140
|
+
transform = axes.transData
|
|
141
|
+
|
|
142
|
+
if color is None:
|
|
143
|
+
color = axes._get_lines.get_next_color()
|
|
144
|
+
|
|
145
|
+
linewidth = mpl._val_or_rc(linewidth, 'lines.linewidth')
|
|
146
|
+
|
|
147
|
+
line_kw = {}
|
|
148
|
+
arrow_kw = dict(arrowstyle=arrowstyle, mutation_scale=10 * arrowsize)
|
|
149
|
+
|
|
150
|
+
_api.check_in_list(['both', 'forward', 'backward'],
|
|
151
|
+
integration_direction=integration_direction)
|
|
152
|
+
|
|
153
|
+
if integration_direction == 'both':
|
|
154
|
+
maxlength /= 2.
|
|
155
|
+
|
|
156
|
+
use_multicolor_lines = isinstance(color, np.ndarray)
|
|
157
|
+
if use_multicolor_lines:
|
|
158
|
+
if color.shape != grid.shape:
|
|
159
|
+
raise ValueError("If 'color' is given, it must match the shape of "
|
|
160
|
+
"the (x, y) grid")
|
|
161
|
+
line_colors = [[]] # Empty entry allows concatenation of zero arrays.
|
|
162
|
+
color = np.ma.masked_invalid(color)
|
|
163
|
+
else:
|
|
164
|
+
line_kw['color'] = color
|
|
165
|
+
arrow_kw['color'] = color
|
|
166
|
+
|
|
167
|
+
if isinstance(linewidth, np.ndarray):
|
|
168
|
+
if linewidth.shape != grid.shape:
|
|
169
|
+
raise ValueError("If 'linewidth' is given, it must match the "
|
|
170
|
+
"shape of the (x, y) grid")
|
|
171
|
+
line_kw['linewidth'] = []
|
|
172
|
+
else:
|
|
173
|
+
line_kw['linewidth'] = linewidth
|
|
174
|
+
arrow_kw['linewidth'] = linewidth
|
|
175
|
+
|
|
176
|
+
line_kw['zorder'] = zorder
|
|
177
|
+
arrow_kw['zorder'] = zorder
|
|
178
|
+
|
|
179
|
+
# Sanity checks.
|
|
180
|
+
if u.shape != grid.shape or v.shape != grid.shape:
|
|
181
|
+
raise ValueError("'u' and 'v' must match the shape of the (x, y) grid")
|
|
182
|
+
|
|
183
|
+
u = np.ma.masked_invalid(u)
|
|
184
|
+
v = np.ma.masked_invalid(v)
|
|
185
|
+
|
|
186
|
+
integrate = _get_integrator(u, v, dmap, minlength, maxlength,
|
|
187
|
+
integration_direction)
|
|
188
|
+
|
|
189
|
+
trajectories = []
|
|
190
|
+
if start_points is None:
|
|
191
|
+
for xm, ym in _gen_starting_points(mask.shape):
|
|
192
|
+
if mask[ym, xm] == 0:
|
|
193
|
+
xg, yg = dmap.mask2grid(xm, ym)
|
|
194
|
+
t = integrate(xg, yg, broken_streamlines,
|
|
195
|
+
integration_max_step_scale,
|
|
196
|
+
integration_max_error_scale)
|
|
197
|
+
if t is not None:
|
|
198
|
+
trajectories.append(t)
|
|
199
|
+
else:
|
|
200
|
+
sp2 = np.asanyarray(start_points, dtype=float).copy()
|
|
201
|
+
|
|
202
|
+
# Check if start_points are outside the data boundaries
|
|
203
|
+
for xs, ys in sp2:
|
|
204
|
+
if not (grid.x_origin <= xs <= grid.x_origin + grid.width and
|
|
205
|
+
grid.y_origin <= ys <= grid.y_origin + grid.height):
|
|
206
|
+
raise ValueError(f"Starting point ({xs}, {ys}) outside of "
|
|
207
|
+
"data boundaries")
|
|
208
|
+
|
|
209
|
+
# Convert start_points from data to array coords
|
|
210
|
+
# Shift the seed points from the bottom left of the data so that
|
|
211
|
+
# data2grid works properly.
|
|
212
|
+
sp2[:, 0] -= grid.x_origin
|
|
213
|
+
sp2[:, 1] -= grid.y_origin
|
|
214
|
+
|
|
215
|
+
for xs, ys in sp2:
|
|
216
|
+
xg, yg = dmap.data2grid(xs, ys)
|
|
217
|
+
# Floating point issues can cause xg, yg to be slightly out of
|
|
218
|
+
# bounds for xs, ys on the upper boundaries. Because we have
|
|
219
|
+
# already checked that the starting points are within the original
|
|
220
|
+
# grid, clip the xg, yg to the grid to work around this issue
|
|
221
|
+
xg = np.clip(xg, 0, grid.nx - 1)
|
|
222
|
+
yg = np.clip(yg, 0, grid.ny - 1)
|
|
223
|
+
|
|
224
|
+
t = integrate(xg, yg, broken_streamlines, integration_max_step_scale,
|
|
225
|
+
integration_max_error_scale)
|
|
226
|
+
if t is not None:
|
|
227
|
+
trajectories.append(t)
|
|
228
|
+
|
|
229
|
+
if use_multicolor_lines:
|
|
230
|
+
if norm is None:
|
|
231
|
+
norm = mcolors.Normalize(color.min(), color.max())
|
|
232
|
+
cmap = colorizer._ensure_cmap(cmap)
|
|
233
|
+
|
|
234
|
+
streamlines = []
|
|
235
|
+
arrows = []
|
|
236
|
+
for t in trajectories:
|
|
237
|
+
tgx, tgy = t.T
|
|
238
|
+
# Rescale from grid-coordinates to data-coordinates.
|
|
239
|
+
tx, ty = dmap.grid2data(tgx, tgy)
|
|
240
|
+
tx += grid.x_origin
|
|
241
|
+
ty += grid.y_origin
|
|
242
|
+
|
|
243
|
+
# Create multiple tiny segments if varying width or color is given
|
|
244
|
+
if isinstance(linewidth, np.ndarray) or use_multicolor_lines:
|
|
245
|
+
points = np.transpose([tx, ty]).reshape(-1, 1, 2)
|
|
246
|
+
streamlines.extend(np.hstack([points[:-1], points[1:]]))
|
|
247
|
+
else:
|
|
248
|
+
points = np.transpose([tx, ty])
|
|
249
|
+
streamlines.append(points)
|
|
250
|
+
|
|
251
|
+
# Distance along streamline
|
|
252
|
+
s = np.cumsum(np.hypot(np.diff(tx), np.diff(ty)))
|
|
253
|
+
if isinstance(linewidth, np.ndarray):
|
|
254
|
+
line_widths = interpgrid(linewidth, tgx, tgy)[:-1]
|
|
255
|
+
line_kw['linewidth'].extend(line_widths)
|
|
256
|
+
if use_multicolor_lines:
|
|
257
|
+
color_values = interpgrid(color, tgx, tgy)[:-1]
|
|
258
|
+
line_colors.append(color_values)
|
|
259
|
+
|
|
260
|
+
# Add arrows along each trajectory.
|
|
261
|
+
for x in range(1, num_arrows+1):
|
|
262
|
+
# Get index of distance along streamline to place arrow
|
|
263
|
+
idx = np.searchsorted(s, s[-1] * (x/(num_arrows+1)))
|
|
264
|
+
arrow_tail = (tx[idx], ty[idx])
|
|
265
|
+
arrow_head = (np.mean(tx[idx:idx + 2]), np.mean(ty[idx:idx + 2]))
|
|
266
|
+
|
|
267
|
+
if isinstance(linewidth, np.ndarray):
|
|
268
|
+
arrow_kw['linewidth'] = line_widths[idx]
|
|
269
|
+
|
|
270
|
+
if use_multicolor_lines:
|
|
271
|
+
arrow_kw['color'] = cmap(norm(color_values[idx]))
|
|
272
|
+
|
|
273
|
+
p = patches.FancyArrowPatch(
|
|
274
|
+
arrow_tail, arrow_head, transform=transform, **arrow_kw)
|
|
275
|
+
arrows.append(p)
|
|
276
|
+
|
|
277
|
+
lc = mcollections.LineCollection(
|
|
278
|
+
streamlines, transform=transform, **line_kw)
|
|
279
|
+
lc.sticky_edges.x[:] = [grid.x_origin, grid.x_origin + grid.width]
|
|
280
|
+
lc.sticky_edges.y[:] = [grid.y_origin, grid.y_origin + grid.height]
|
|
281
|
+
if use_multicolor_lines:
|
|
282
|
+
lc.set_array(np.ma.hstack(line_colors))
|
|
283
|
+
lc.set_cmap(cmap)
|
|
284
|
+
lc.set_norm(norm)
|
|
285
|
+
axes.add_collection(lc)
|
|
286
|
+
|
|
287
|
+
ac = mcollections.PatchCollection(arrows)
|
|
288
|
+
# Adding the collection itself is broken; see #2341.
|
|
289
|
+
for p in arrows:
|
|
290
|
+
axes.add_patch(p)
|
|
291
|
+
|
|
292
|
+
axes.autoscale_view()
|
|
293
|
+
stream_container = StreamplotSet(lc, ac)
|
|
294
|
+
return stream_container
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
class StreamplotSet:
|
|
298
|
+
|
|
299
|
+
def __init__(self, lines, arrows):
|
|
300
|
+
self.lines = lines
|
|
301
|
+
self.arrows = arrows
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
# Coordinate definitions
|
|
305
|
+
# ========================
|
|
306
|
+
|
|
307
|
+
class DomainMap:
|
|
308
|
+
"""
|
|
309
|
+
Map representing different coordinate systems.
|
|
310
|
+
|
|
311
|
+
Coordinate definitions:
|
|
312
|
+
|
|
313
|
+
* axes-coordinates goes from 0 to 1 in the domain.
|
|
314
|
+
* data-coordinates are specified by the input x-y coordinates.
|
|
315
|
+
* grid-coordinates goes from 0 to N and 0 to M for an N x M grid,
|
|
316
|
+
where N and M match the shape of the input data.
|
|
317
|
+
* mask-coordinates goes from 0 to N and 0 to M for an N x M mask,
|
|
318
|
+
where N and M are user-specified to control the density of streamlines.
|
|
319
|
+
|
|
320
|
+
This class also has methods for adding trajectories to the StreamMask.
|
|
321
|
+
Before adding a trajectory, run `start_trajectory` to keep track of regions
|
|
322
|
+
crossed by a given trajectory. Later, if you decide the trajectory is bad
|
|
323
|
+
(e.g., if the trajectory is very short) just call `undo_trajectory`.
|
|
324
|
+
"""
|
|
325
|
+
|
|
326
|
+
def __init__(self, grid, mask):
|
|
327
|
+
self.grid = grid
|
|
328
|
+
self.mask = mask
|
|
329
|
+
# Constants for conversion between grid- and mask-coordinates
|
|
330
|
+
self.x_grid2mask = (mask.nx - 1) / (grid.nx - 1)
|
|
331
|
+
self.y_grid2mask = (mask.ny - 1) / (grid.ny - 1)
|
|
332
|
+
|
|
333
|
+
self.x_mask2grid = 1. / self.x_grid2mask
|
|
334
|
+
self.y_mask2grid = 1. / self.y_grid2mask
|
|
335
|
+
|
|
336
|
+
self.x_data2grid = 1. / grid.dx
|
|
337
|
+
self.y_data2grid = 1. / grid.dy
|
|
338
|
+
|
|
339
|
+
def grid2mask(self, xi, yi):
|
|
340
|
+
"""Return nearest space in mask-coords from given grid-coords."""
|
|
341
|
+
return round(xi * self.x_grid2mask), round(yi * self.y_grid2mask)
|
|
342
|
+
|
|
343
|
+
def mask2grid(self, xm, ym):
|
|
344
|
+
return xm * self.x_mask2grid, ym * self.y_mask2grid
|
|
345
|
+
|
|
346
|
+
def data2grid(self, xd, yd):
|
|
347
|
+
return xd * self.x_data2grid, yd * self.y_data2grid
|
|
348
|
+
|
|
349
|
+
def grid2data(self, xg, yg):
|
|
350
|
+
return xg / self.x_data2grid, yg / self.y_data2grid
|
|
351
|
+
|
|
352
|
+
def start_trajectory(self, xg, yg, broken_streamlines=True):
|
|
353
|
+
xm, ym = self.grid2mask(xg, yg)
|
|
354
|
+
self.mask._start_trajectory(xm, ym, broken_streamlines)
|
|
355
|
+
|
|
356
|
+
def reset_start_point(self, xg, yg):
|
|
357
|
+
xm, ym = self.grid2mask(xg, yg)
|
|
358
|
+
self.mask._current_xy = (xm, ym)
|
|
359
|
+
|
|
360
|
+
def update_trajectory(self, xg, yg, broken_streamlines=True):
|
|
361
|
+
if not self.grid.within_grid(xg, yg):
|
|
362
|
+
raise InvalidIndexError
|
|
363
|
+
xm, ym = self.grid2mask(xg, yg)
|
|
364
|
+
self.mask._update_trajectory(xm, ym, broken_streamlines)
|
|
365
|
+
|
|
366
|
+
def undo_trajectory(self):
|
|
367
|
+
self.mask._undo_trajectory()
|
|
368
|
+
|
|
369
|
+
|
|
370
|
+
class Grid:
|
|
371
|
+
"""Grid of data."""
|
|
372
|
+
def __init__(self, x, y):
|
|
373
|
+
|
|
374
|
+
if np.ndim(x) == 1:
|
|
375
|
+
pass
|
|
376
|
+
elif np.ndim(x) == 2:
|
|
377
|
+
x_row = x[0]
|
|
378
|
+
if not np.allclose(x_row, x):
|
|
379
|
+
raise ValueError("The rows of 'x' must be equal")
|
|
380
|
+
x = x_row
|
|
381
|
+
else:
|
|
382
|
+
raise ValueError("'x' can have at maximum 2 dimensions")
|
|
383
|
+
|
|
384
|
+
if np.ndim(y) == 1:
|
|
385
|
+
pass
|
|
386
|
+
elif np.ndim(y) == 2:
|
|
387
|
+
yt = np.transpose(y) # Also works for nested lists.
|
|
388
|
+
y_col = yt[0]
|
|
389
|
+
if not np.allclose(y_col, yt):
|
|
390
|
+
raise ValueError("The columns of 'y' must be equal")
|
|
391
|
+
y = y_col
|
|
392
|
+
else:
|
|
393
|
+
raise ValueError("'y' can have at maximum 2 dimensions")
|
|
394
|
+
|
|
395
|
+
if not (np.diff(x) > 0).all():
|
|
396
|
+
raise ValueError("'x' must be strictly increasing")
|
|
397
|
+
if not (np.diff(y) > 0).all():
|
|
398
|
+
raise ValueError("'y' must be strictly increasing")
|
|
399
|
+
|
|
400
|
+
self.nx = len(x)
|
|
401
|
+
self.ny = len(y)
|
|
402
|
+
|
|
403
|
+
self.dx = x[1] - x[0]
|
|
404
|
+
self.dy = y[1] - y[0]
|
|
405
|
+
|
|
406
|
+
self.x_origin = x[0]
|
|
407
|
+
self.y_origin = y[0]
|
|
408
|
+
|
|
409
|
+
self.width = x[-1] - x[0]
|
|
410
|
+
self.height = y[-1] - y[0]
|
|
411
|
+
|
|
412
|
+
if not np.allclose(np.diff(x), self.width / (self.nx - 1)):
|
|
413
|
+
raise ValueError("'x' values must be equally spaced")
|
|
414
|
+
if not np.allclose(np.diff(y), self.height / (self.ny - 1)):
|
|
415
|
+
raise ValueError("'y' values must be equally spaced")
|
|
416
|
+
|
|
417
|
+
@property
|
|
418
|
+
def shape(self):
|
|
419
|
+
return self.ny, self.nx
|
|
420
|
+
|
|
421
|
+
def within_grid(self, xi, yi):
|
|
422
|
+
"""Return whether (*xi*, *yi*) is a valid index of the grid."""
|
|
423
|
+
# Note that xi/yi can be floats; so, for example, we can't simply check
|
|
424
|
+
# `xi < self.nx` since *xi* can be `self.nx - 1 < xi < self.nx`
|
|
425
|
+
return 0 <= xi <= self.nx - 1 and 0 <= yi <= self.ny - 1
|
|
426
|
+
|
|
427
|
+
|
|
428
|
+
class StreamMask:
|
|
429
|
+
"""
|
|
430
|
+
Mask to keep track of discrete regions crossed by streamlines.
|
|
431
|
+
|
|
432
|
+
The resolution of this grid determines the approximate spacing between
|
|
433
|
+
trajectories. Streamlines are only allowed to pass through zeroed cells:
|
|
434
|
+
When a streamline enters a cell, that cell is set to 1, and no new
|
|
435
|
+
streamlines are allowed to enter.
|
|
436
|
+
"""
|
|
437
|
+
|
|
438
|
+
def __init__(self, density):
|
|
439
|
+
try:
|
|
440
|
+
self.nx, self.ny = (30 * np.broadcast_to(density, 2)).astype(int)
|
|
441
|
+
except ValueError as err:
|
|
442
|
+
raise ValueError("'density' must be a scalar or be of length "
|
|
443
|
+
"2") from err
|
|
444
|
+
if self.nx < 0 or self.ny < 0:
|
|
445
|
+
raise ValueError("'density' must be positive")
|
|
446
|
+
self._mask = np.zeros((self.ny, self.nx))
|
|
447
|
+
self.shape = self._mask.shape
|
|
448
|
+
|
|
449
|
+
self._current_xy = None
|
|
450
|
+
|
|
451
|
+
def __getitem__(self, args):
|
|
452
|
+
return self._mask[args]
|
|
453
|
+
|
|
454
|
+
def _start_trajectory(self, xm, ym, broken_streamlines=True):
|
|
455
|
+
"""Start recording streamline trajectory"""
|
|
456
|
+
self._traj = []
|
|
457
|
+
self._update_trajectory(xm, ym, broken_streamlines)
|
|
458
|
+
|
|
459
|
+
def _undo_trajectory(self):
|
|
460
|
+
"""Remove current trajectory from mask"""
|
|
461
|
+
for t in self._traj:
|
|
462
|
+
self._mask[t] = 0
|
|
463
|
+
|
|
464
|
+
def _update_trajectory(self, xm, ym, broken_streamlines=True):
|
|
465
|
+
"""
|
|
466
|
+
Update current trajectory position in mask.
|
|
467
|
+
|
|
468
|
+
If the new position has already been filled, raise `InvalidIndexError`.
|
|
469
|
+
"""
|
|
470
|
+
if self._current_xy != (xm, ym):
|
|
471
|
+
if self[ym, xm] == 0:
|
|
472
|
+
self._traj.append((ym, xm))
|
|
473
|
+
self._mask[ym, xm] = 1
|
|
474
|
+
self._current_xy = (xm, ym)
|
|
475
|
+
else:
|
|
476
|
+
if broken_streamlines:
|
|
477
|
+
raise InvalidIndexError
|
|
478
|
+
else:
|
|
479
|
+
pass
|
|
480
|
+
|
|
481
|
+
|
|
482
|
+
class InvalidIndexError(Exception):
|
|
483
|
+
pass
|
|
484
|
+
|
|
485
|
+
|
|
486
|
+
class TerminateTrajectory(Exception):
|
|
487
|
+
pass
|
|
488
|
+
|
|
489
|
+
|
|
490
|
+
# Integrator definitions
|
|
491
|
+
# =======================
|
|
492
|
+
|
|
493
|
+
def _get_integrator(u, v, dmap, minlength, maxlength, integration_direction):
|
|
494
|
+
|
|
495
|
+
# rescale velocity onto grid-coordinates for integrations.
|
|
496
|
+
u, v = dmap.data2grid(u, v)
|
|
497
|
+
|
|
498
|
+
# speed (path length) will be in axes-coordinates
|
|
499
|
+
u_ax = u / (dmap.grid.nx - 1)
|
|
500
|
+
v_ax = v / (dmap.grid.ny - 1)
|
|
501
|
+
speed = np.ma.sqrt(u_ax ** 2 + v_ax ** 2)
|
|
502
|
+
|
|
503
|
+
def forward_time(xi, yi):
|
|
504
|
+
if not dmap.grid.within_grid(xi, yi):
|
|
505
|
+
raise OutOfBounds
|
|
506
|
+
ds_dt = interpgrid(speed, xi, yi)
|
|
507
|
+
if ds_dt == 0:
|
|
508
|
+
raise TerminateTrajectory()
|
|
509
|
+
dt_ds = 1. / ds_dt
|
|
510
|
+
ui = interpgrid(u, xi, yi)
|
|
511
|
+
vi = interpgrid(v, xi, yi)
|
|
512
|
+
return ui * dt_ds, vi * dt_ds
|
|
513
|
+
|
|
514
|
+
def backward_time(xi, yi):
|
|
515
|
+
dxi, dyi = forward_time(xi, yi)
|
|
516
|
+
return -dxi, -dyi
|
|
517
|
+
|
|
518
|
+
def integrate(x0, y0, broken_streamlines=True, integration_max_step_scale=1.0,
|
|
519
|
+
integration_max_error_scale=1.0):
|
|
520
|
+
"""
|
|
521
|
+
Return x, y grid-coordinates of trajectory based on starting point.
|
|
522
|
+
|
|
523
|
+
Integrate both forward and backward in time from starting point in
|
|
524
|
+
grid coordinates.
|
|
525
|
+
|
|
526
|
+
Integration is terminated when a trajectory reaches a domain boundary
|
|
527
|
+
or when it crosses into an already occupied cell in the StreamMask. The
|
|
528
|
+
resulting trajectory is None if it is shorter than `minlength`.
|
|
529
|
+
"""
|
|
530
|
+
|
|
531
|
+
stotal, xy_traj = 0., []
|
|
532
|
+
|
|
533
|
+
try:
|
|
534
|
+
dmap.start_trajectory(x0, y0, broken_streamlines)
|
|
535
|
+
except InvalidIndexError:
|
|
536
|
+
return None
|
|
537
|
+
if integration_direction in ['both', 'backward']:
|
|
538
|
+
s, xyt = _integrate_rk12(x0, y0, dmap, backward_time, maxlength,
|
|
539
|
+
broken_streamlines,
|
|
540
|
+
integration_max_step_scale,
|
|
541
|
+
integration_max_error_scale)
|
|
542
|
+
stotal += s
|
|
543
|
+
xy_traj += xyt[::-1]
|
|
544
|
+
|
|
545
|
+
if integration_direction in ['both', 'forward']:
|
|
546
|
+
dmap.reset_start_point(x0, y0)
|
|
547
|
+
s, xyt = _integrate_rk12(x0, y0, dmap, forward_time, maxlength,
|
|
548
|
+
broken_streamlines,
|
|
549
|
+
integration_max_step_scale,
|
|
550
|
+
integration_max_error_scale)
|
|
551
|
+
stotal += s
|
|
552
|
+
xy_traj += xyt[1:]
|
|
553
|
+
|
|
554
|
+
if stotal > minlength:
|
|
555
|
+
return np.broadcast_arrays(xy_traj, np.empty((1, 2)))[0]
|
|
556
|
+
else: # reject short trajectories
|
|
557
|
+
dmap.undo_trajectory()
|
|
558
|
+
return None
|
|
559
|
+
|
|
560
|
+
return integrate
|
|
561
|
+
|
|
562
|
+
|
|
563
|
+
class OutOfBounds(IndexError):
|
|
564
|
+
pass
|
|
565
|
+
|
|
566
|
+
|
|
567
|
+
def _integrate_rk12(x0, y0, dmap, f, maxlength, broken_streamlines=True,
|
|
568
|
+
integration_max_step_scale=1.0,
|
|
569
|
+
integration_max_error_scale=1.0):
|
|
570
|
+
"""
|
|
571
|
+
2nd-order Runge-Kutta algorithm with adaptive step size.
|
|
572
|
+
|
|
573
|
+
This method is also referred to as the improved Euler's method, or Heun's
|
|
574
|
+
method. This method is favored over higher-order methods because:
|
|
575
|
+
|
|
576
|
+
1. To get decent looking trajectories and to sample every mask cell
|
|
577
|
+
on the trajectory we need a small timestep, so a lower order
|
|
578
|
+
solver doesn't hurt us unless the data is *very* high resolution.
|
|
579
|
+
In fact, for cases where the user inputs
|
|
580
|
+
data smaller or of similar grid size to the mask grid, the higher
|
|
581
|
+
order corrections are negligible because of the very fast linear
|
|
582
|
+
interpolation used in `interpgrid`.
|
|
583
|
+
|
|
584
|
+
2. For high resolution input data (i.e. beyond the mask
|
|
585
|
+
resolution), we must reduce the timestep. Therefore, an adaptive
|
|
586
|
+
timestep is more suited to the problem as this would be very hard
|
|
587
|
+
to judge automatically otherwise.
|
|
588
|
+
|
|
589
|
+
This integrator is about 1.5 - 2x as fast as RK4 and RK45 solvers (using
|
|
590
|
+
similar Python implementations) in most setups.
|
|
591
|
+
"""
|
|
592
|
+
# This error is below that needed to match the RK4 integrator. It
|
|
593
|
+
# is set for visual reasons -- too low and corners start
|
|
594
|
+
# appearing ugly and jagged. Can be tuned.
|
|
595
|
+
maxerror = 0.003 * integration_max_error_scale
|
|
596
|
+
|
|
597
|
+
# This limit is important (for all integrators) to avoid the
|
|
598
|
+
# trajectory skipping some mask cells. We could relax this
|
|
599
|
+
# condition if we use the code which is commented out below to
|
|
600
|
+
# increment the location gradually. However, due to the efficient
|
|
601
|
+
# nature of the interpolation, this doesn't boost speed by much
|
|
602
|
+
# for quite a bit of complexity.
|
|
603
|
+
maxds = min(1. / dmap.mask.nx, 1. / dmap.mask.ny, 0.1)
|
|
604
|
+
maxds *= integration_max_step_scale
|
|
605
|
+
|
|
606
|
+
ds = maxds
|
|
607
|
+
stotal = 0
|
|
608
|
+
xi = x0
|
|
609
|
+
yi = y0
|
|
610
|
+
xyf_traj = []
|
|
611
|
+
|
|
612
|
+
while True:
|
|
613
|
+
try:
|
|
614
|
+
if dmap.grid.within_grid(xi, yi):
|
|
615
|
+
xyf_traj.append((xi, yi))
|
|
616
|
+
else:
|
|
617
|
+
raise OutOfBounds
|
|
618
|
+
|
|
619
|
+
# Compute the two intermediate gradients.
|
|
620
|
+
# f should raise OutOfBounds if the locations given are
|
|
621
|
+
# outside the grid.
|
|
622
|
+
k1x, k1y = f(xi, yi)
|
|
623
|
+
k2x, k2y = f(xi + ds * k1x, yi + ds * k1y)
|
|
624
|
+
|
|
625
|
+
except OutOfBounds:
|
|
626
|
+
# Out of the domain during this step.
|
|
627
|
+
# Take an Euler step to the boundary to improve neatness
|
|
628
|
+
# unless the trajectory is currently empty.
|
|
629
|
+
if xyf_traj:
|
|
630
|
+
ds, xyf_traj = _euler_step(xyf_traj, dmap, f)
|
|
631
|
+
stotal += ds
|
|
632
|
+
break
|
|
633
|
+
except TerminateTrajectory:
|
|
634
|
+
break
|
|
635
|
+
|
|
636
|
+
dx1 = ds * k1x
|
|
637
|
+
dy1 = ds * k1y
|
|
638
|
+
dx2 = ds * 0.5 * (k1x + k2x)
|
|
639
|
+
dy2 = ds * 0.5 * (k1y + k2y)
|
|
640
|
+
|
|
641
|
+
ny, nx = dmap.grid.shape
|
|
642
|
+
# Error is normalized to the axes coordinates
|
|
643
|
+
error = np.hypot((dx2 - dx1) / (nx - 1), (dy2 - dy1) / (ny - 1))
|
|
644
|
+
|
|
645
|
+
# Only save step if within error tolerance
|
|
646
|
+
if error < maxerror:
|
|
647
|
+
xi += dx2
|
|
648
|
+
yi += dy2
|
|
649
|
+
try:
|
|
650
|
+
dmap.update_trajectory(xi, yi, broken_streamlines)
|
|
651
|
+
except InvalidIndexError:
|
|
652
|
+
break
|
|
653
|
+
if stotal + ds > maxlength:
|
|
654
|
+
break
|
|
655
|
+
stotal += ds
|
|
656
|
+
|
|
657
|
+
# recalculate stepsize based on step error
|
|
658
|
+
if error == 0:
|
|
659
|
+
ds = maxds
|
|
660
|
+
else:
|
|
661
|
+
ds = min(maxds, 0.85 * ds * (maxerror / error) ** 0.5)
|
|
662
|
+
|
|
663
|
+
return stotal, xyf_traj
|
|
664
|
+
|
|
665
|
+
|
|
666
|
+
def _euler_step(xyf_traj, dmap, f):
|
|
667
|
+
"""Simple Euler integration step that extends streamline to boundary."""
|
|
668
|
+
ny, nx = dmap.grid.shape
|
|
669
|
+
xi, yi = xyf_traj[-1]
|
|
670
|
+
cx, cy = f(xi, yi)
|
|
671
|
+
if cx == 0:
|
|
672
|
+
dsx = np.inf
|
|
673
|
+
elif cx < 0:
|
|
674
|
+
dsx = xi / -cx
|
|
675
|
+
else:
|
|
676
|
+
dsx = (nx - 1 - xi) / cx
|
|
677
|
+
if cy == 0:
|
|
678
|
+
dsy = np.inf
|
|
679
|
+
elif cy < 0:
|
|
680
|
+
dsy = yi / -cy
|
|
681
|
+
else:
|
|
682
|
+
dsy = (ny - 1 - yi) / cy
|
|
683
|
+
ds = min(dsx, dsy)
|
|
684
|
+
xyf_traj.append((xi + cx * ds, yi + cy * ds))
|
|
685
|
+
return ds, xyf_traj
|
|
686
|
+
|
|
687
|
+
|
|
688
|
+
# Utility functions
|
|
689
|
+
# ========================
|
|
690
|
+
|
|
691
|
+
def interpgrid(a, xi, yi):
|
|
692
|
+
"""Fast 2D, linear interpolation on an integer grid"""
|
|
693
|
+
|
|
694
|
+
Ny, Nx = np.shape(a)
|
|
695
|
+
if isinstance(xi, np.ndarray):
|
|
696
|
+
x = xi.astype(int)
|
|
697
|
+
y = yi.astype(int)
|
|
698
|
+
# Check that xn, yn don't exceed max index
|
|
699
|
+
xn = np.clip(x + 1, 0, Nx - 1)
|
|
700
|
+
yn = np.clip(y + 1, 0, Ny - 1)
|
|
701
|
+
else:
|
|
702
|
+
x = int(xi)
|
|
703
|
+
y = int(yi)
|
|
704
|
+
# conditional is faster than clipping for integers
|
|
705
|
+
if x == (Nx - 1):
|
|
706
|
+
xn = x
|
|
707
|
+
else:
|
|
708
|
+
xn = x + 1
|
|
709
|
+
if y == (Ny - 1):
|
|
710
|
+
yn = y
|
|
711
|
+
else:
|
|
712
|
+
yn = y + 1
|
|
713
|
+
|
|
714
|
+
a00 = a[y, x]
|
|
715
|
+
a01 = a[y, xn]
|
|
716
|
+
a10 = a[yn, x]
|
|
717
|
+
a11 = a[yn, xn]
|
|
718
|
+
xt = xi - x
|
|
719
|
+
yt = yi - y
|
|
720
|
+
a0 = a00 * (1 - xt) + a01 * xt
|
|
721
|
+
a1 = a10 * (1 - xt) + a11 * xt
|
|
722
|
+
ai = a0 * (1 - yt) + a1 * yt
|
|
723
|
+
|
|
724
|
+
if not isinstance(xi, np.ndarray):
|
|
725
|
+
if np.ma.is_masked(ai):
|
|
726
|
+
raise TerminateTrajectory
|
|
727
|
+
|
|
728
|
+
return ai
|
|
729
|
+
|
|
730
|
+
|
|
731
|
+
def _gen_starting_points(shape):
|
|
732
|
+
"""
|
|
733
|
+
Yield starting points for streamlines.
|
|
734
|
+
|
|
735
|
+
Trying points on the boundary first gives higher quality streamlines.
|
|
736
|
+
This algorithm starts with a point on the mask corner and spirals inward.
|
|
737
|
+
This algorithm is inefficient, but fast compared to rest of streamplot.
|
|
738
|
+
"""
|
|
739
|
+
ny, nx = shape
|
|
740
|
+
xfirst = 0
|
|
741
|
+
yfirst = 1
|
|
742
|
+
xlast = nx - 1
|
|
743
|
+
ylast = ny - 1
|
|
744
|
+
x, y = 0, 0
|
|
745
|
+
direction = 'right'
|
|
746
|
+
for i in range(nx * ny):
|
|
747
|
+
yield x, y
|
|
748
|
+
|
|
749
|
+
if direction == 'right':
|
|
750
|
+
x += 1
|
|
751
|
+
if x >= xlast:
|
|
752
|
+
xlast -= 1
|
|
753
|
+
direction = 'up'
|
|
754
|
+
elif direction == 'up':
|
|
755
|
+
y += 1
|
|
756
|
+
if y >= ylast:
|
|
757
|
+
ylast -= 1
|
|
758
|
+
direction = 'left'
|
|
759
|
+
elif direction == 'left':
|
|
760
|
+
x -= 1
|
|
761
|
+
if x <= xfirst:
|
|
762
|
+
xfirst += 1
|
|
763
|
+
direction = 'down'
|
|
764
|
+
elif direction == 'down':
|
|
765
|
+
y -= 1
|
|
766
|
+
if y <= yfirst:
|
|
767
|
+
yfirst += 1
|
|
768
|
+
direction = 'right'
|