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.
Files changed (352) hide show
  1. docs/releases/0.0.1.md +268 -0
  2. docs/releases/0.0.2.md +69 -0
  3. docs/releases/0.0.3.md +80 -0
  4. docs/releases/0.0.4.md +73 -0
  5. docs/releases/0.0.5.md +24 -0
  6. docs/releases/0.0.6.md +24 -0
  7. docs/releases/0.0.7.md +24 -0
  8. docs/releases/0.0.8.md +16 -0
  9. licenses/LICENSE_CONTOURPY +29 -0
  10. licenses/LICENSE_CYCLER +27 -0
  11. licenses/LICENSE_DATEUTIL +54 -0
  12. licenses/LICENSE_KIWISOLVER +71 -0
  13. licenses/LICENSE_LIBWEBP +56 -0
  14. licenses/LICENSE_MATPLOTLIB +1253 -0
  15. licenses/LICENSE_PYPARSING +20 -0
  16. licenses/LICENSE_QHULL +39 -0
  17. licenses/LICENSE_SIX +18 -0
  18. matplotlib_rs/__init__.py +1683 -0
  19. matplotlib_rs/__main__.py +27 -0
  20. matplotlib_rs/_afm.py +500 -0
  21. matplotlib_rs/_animation_data.py +263 -0
  22. matplotlib_rs/_api/__init__.py +495 -0
  23. matplotlib_rs/_api/deprecation.py +534 -0
  24. matplotlib_rs/_axis_py.py +2991 -0
  25. matplotlib_rs/_blocking_input.py +31 -0
  26. matplotlib_rs/_cm.py +1500 -0
  27. matplotlib_rs/_cm_bivar.py +1289 -0
  28. matplotlib_rs/_cm_listed.py +2848 -0
  29. matplotlib_rs/_cm_multivar.py +167 -0
  30. matplotlib_rs/_color_data.py +1142 -0
  31. matplotlib_rs/_colormap.py +132 -0
  32. matplotlib_rs/_constrained_layout.py +825 -0
  33. matplotlib_rs/_contour.py +108 -0
  34. matplotlib_rs/_doc_cache.py +12214 -0
  35. matplotlib_rs/_docstring.py +142 -0
  36. matplotlib_rs/_enums.py +178 -0
  37. matplotlib_rs/_figure_rs.py +294 -0
  38. matplotlib_rs/_fontconfig_pattern.py +129 -0
  39. matplotlib_rs/_foreign.py +220 -0
  40. matplotlib_rs/_hook.py +94 -0
  41. matplotlib_rs/_image.py +160 -0
  42. matplotlib_rs/_imageio.py +229 -0
  43. matplotlib_rs/_internal_utils.py +65 -0
  44. matplotlib_rs/_kiwi.py +484 -0
  45. matplotlib_rs/_layoutgrid.py +549 -0
  46. matplotlib_rs/_live.py +192 -0
  47. matplotlib_rs/_mathtext.py +3103 -0
  48. matplotlib_rs/_mathtext_data.py +1811 -0
  49. matplotlib_rs/_mplrs.cp315-win_amd64.pyd +0 -0
  50. matplotlib_rs/_path.py +25 -0
  51. matplotlib_rs/_png.py +162 -0
  52. matplotlib_rs/_pylab_helpers.py +137 -0
  53. matplotlib_rs/_qhull.py +66 -0
  54. matplotlib_rs/_rcpush.py +84 -0
  55. matplotlib_rs/_spines_rs.py +108 -0
  56. matplotlib_rs/_style_helpers.py +52 -0
  57. matplotlib_rs/_text_helpers.py +51 -0
  58. matplotlib_rs/_tight_bbox.py +85 -0
  59. matplotlib_rs/_tight_layout.py +302 -0
  60. matplotlib_rs/_tri.py +140 -0
  61. matplotlib_rs/_type1font.py +1228 -0
  62. matplotlib_rs/_vendor/__init__.py +8 -0
  63. matplotlib_rs/_vendor/cycler.py +574 -0
  64. matplotlib_rs/_vendor/dateutil/__init__.py +27 -0
  65. matplotlib_rs/_vendor/dateutil/_common.py +44 -0
  66. matplotlib_rs/_vendor/dateutil/_tzdata_impl.py +148 -0
  67. matplotlib_rs/_vendor/dateutil/_version.py +5 -0
  68. matplotlib_rs/_vendor/dateutil/easter.py +90 -0
  69. matplotlib_rs/_vendor/dateutil/parser/__init__.py +62 -0
  70. matplotlib_rs/_vendor/dateutil/parser/_parser.py +1614 -0
  71. matplotlib_rs/_vendor/dateutil/parser/isoparser.py +417 -0
  72. matplotlib_rs/_vendor/dateutil/relativedelta.py +597 -0
  73. matplotlib_rs/_vendor/dateutil/rrule.py +1765 -0
  74. matplotlib_rs/_vendor/dateutil/tz/__init__.py +61 -0
  75. matplotlib_rs/_vendor/dateutil/tz/_common.py +420 -0
  76. matplotlib_rs/_vendor/dateutil/tz/_factories.py +81 -0
  77. matplotlib_rs/_vendor/dateutil/tz/_tzfile.py +1429 -0
  78. matplotlib_rs/_vendor/dateutil/tz/_tzpath.py +105 -0
  79. matplotlib_rs/_vendor/dateutil/tz/tz.py +1473 -0
  80. matplotlib_rs/_vendor/dateutil/tz/win.py +371 -0
  81. matplotlib_rs/_vendor/dateutil/tzwin.py +3 -0
  82. matplotlib_rs/_vendor/dateutil/utils.py +72 -0
  83. matplotlib_rs/_vendor/dateutil/zoneinfo/__init__.py +234 -0
  84. matplotlib_rs/_vendor/pyparsing/__init__.py +414 -0
  85. matplotlib_rs/_vendor/pyparsing/actions.py +265 -0
  86. matplotlib_rs/_vendor/pyparsing/common.py +571 -0
  87. matplotlib_rs/_vendor/pyparsing/core.py +6973 -0
  88. matplotlib_rs/_vendor/pyparsing/exceptions.py +354 -0
  89. matplotlib_rs/_vendor/pyparsing/helpers.py +1770 -0
  90. matplotlib_rs/_vendor/pyparsing/results.py +929 -0
  91. matplotlib_rs/_vendor/pyparsing/testing.py +399 -0
  92. matplotlib_rs/_vendor/pyparsing/unicode.py +357 -0
  93. matplotlib_rs/_vendor/pyparsing/util.py +515 -0
  94. matplotlib_rs/_vendor/pyparsing/warnings.py +11 -0
  95. matplotlib_rs/_vendor/six.py +1004 -0
  96. matplotlib_rs/animation.py +1843 -0
  97. matplotlib_rs/artist.py +2302 -0
  98. matplotlib_rs/axes/__init__.py +19 -0
  99. matplotlib_rs/axes/_axes.py +9402 -0
  100. matplotlib_rs/axes/_bar.py +185 -0
  101. matplotlib_rs/axes/_base.py +5236 -0
  102. matplotlib_rs/axes/_base_rs.py +727 -0
  103. matplotlib_rs/axes/_boxplot.py +391 -0
  104. matplotlib_rs/axes/_hist.py +99 -0
  105. matplotlib_rs/axes/_secondary_axes.py +357 -0
  106. matplotlib_rs/axis.py +1963 -0
  107. matplotlib_rs/backend_bases.py +3760 -0
  108. matplotlib_rs/backend_managers.py +388 -0
  109. matplotlib_rs/backend_tools.py +1002 -0
  110. matplotlib_rs/backends/__init__.py +6 -0
  111. matplotlib_rs/backends/_backend_pdf_ps.py +451 -0
  112. matplotlib_rs/backends/backend_agg.py +552 -0
  113. matplotlib_rs/backends/backend_mixed.py +123 -0
  114. matplotlib_rs/backends/backend_pdf.py +2711 -0
  115. matplotlib_rs/backends/backend_pgf.py +1031 -0
  116. matplotlib_rs/backends/backend_ps.py +1491 -0
  117. matplotlib_rs/backends/backend_svg.py +1395 -0
  118. matplotlib_rs/backends/backend_template.py +214 -0
  119. matplotlib_rs/backends/registry.py +423 -0
  120. matplotlib_rs/bezier.py +691 -0
  121. matplotlib_rs/category.py +236 -0
  122. matplotlib_rs/cbook.py +2762 -0
  123. matplotlib_rs/cm.py +251 -0
  124. matplotlib_rs/collections.py +2711 -0
  125. matplotlib_rs/colorbar.py +1586 -0
  126. matplotlib_rs/colorizer.py +909 -0
  127. matplotlib_rs/colors.py +4278 -0
  128. matplotlib_rs/container.py +256 -0
  129. matplotlib_rs/contour.py +1756 -0
  130. matplotlib_rs/dates.py +1847 -0
  131. matplotlib_rs/dviread.py +1386 -0
  132. matplotlib_rs/figure.py +3815 -0
  133. matplotlib_rs/font_manager.py +1855 -0
  134. matplotlib_rs/ft2font.py +515 -0
  135. matplotlib_rs/gridspec.py +808 -0
  136. matplotlib_rs/hatch.py +244 -0
  137. matplotlib_rs/image.py +1863 -0
  138. matplotlib_rs/inset.py +291 -0
  139. matplotlib_rs/layout_engine.py +310 -0
  140. matplotlib_rs/legend.py +1480 -0
  141. matplotlib_rs/legend_handler.py +812 -0
  142. matplotlib_rs/lines.py +1886 -0
  143. matplotlib_rs/markers.py +908 -0
  144. matplotlib_rs/mathtext.py +141 -0
  145. matplotlib_rs/mlab.py +959 -0
  146. matplotlib_rs/mpl-data/fonts/ttf/DejaVuSans-Bold.ttf +0 -0
  147. matplotlib_rs/mpl-data/fonts/ttf/DejaVuSans-BoldOblique.ttf +0 -0
  148. matplotlib_rs/mpl-data/fonts/ttf/DejaVuSans-Oblique.ttf +0 -0
  149. matplotlib_rs/mpl-data/fonts/ttf/DejaVuSans.ttf +0 -0
  150. matplotlib_rs/mpl-data/fonts/ttf/DejaVuSansDisplay.ttf +0 -0
  151. matplotlib_rs/mpl-data/fonts/ttf/DejaVuSansMono-Bold.ttf +0 -0
  152. matplotlib_rs/mpl-data/fonts/ttf/DejaVuSansMono-BoldOblique.ttf +0 -0
  153. matplotlib_rs/mpl-data/fonts/ttf/DejaVuSansMono-Oblique.ttf +0 -0
  154. matplotlib_rs/mpl-data/fonts/ttf/DejaVuSansMono.ttf +0 -0
  155. matplotlib_rs/mpl-data/fonts/ttf/DejaVuSerif-Bold.ttf +0 -0
  156. matplotlib_rs/mpl-data/fonts/ttf/DejaVuSerif-BoldItalic.ttf +0 -0
  157. matplotlib_rs/mpl-data/fonts/ttf/DejaVuSerif-Italic.ttf +0 -0
  158. matplotlib_rs/mpl-data/fonts/ttf/DejaVuSerif.ttf +0 -0
  159. matplotlib_rs/mpl-data/fonts/ttf/DejaVuSerifDisplay.ttf +0 -0
  160. matplotlib_rs/mpl-data/fonts/ttf/LICENSE_DEJAVU +99 -0
  161. matplotlib_rs/mpl-data/fonts/ttf/LICENSE_STIX +124 -0
  162. matplotlib_rs/mpl-data/fonts/ttf/LastResortHE-Regular.ttf +0 -0
  163. matplotlib_rs/mpl-data/fonts/ttf/STIXGeneral.ttf +0 -0
  164. matplotlib_rs/mpl-data/fonts/ttf/STIXGeneralBol.ttf +0 -0
  165. matplotlib_rs/mpl-data/fonts/ttf/STIXGeneralBolIta.ttf +0 -0
  166. matplotlib_rs/mpl-data/fonts/ttf/STIXGeneralItalic.ttf +0 -0
  167. matplotlib_rs/mpl-data/fonts/ttf/STIXNonUni.ttf +0 -0
  168. matplotlib_rs/mpl-data/fonts/ttf/STIXNonUniBol.ttf +0 -0
  169. matplotlib_rs/mpl-data/fonts/ttf/STIXNonUniBolIta.ttf +0 -0
  170. matplotlib_rs/mpl-data/fonts/ttf/STIXNonUniIta.ttf +0 -0
  171. matplotlib_rs/mpl-data/fonts/ttf/STIXSizFiveSymReg.ttf +0 -0
  172. matplotlib_rs/mpl-data/fonts/ttf/STIXSizFourSymBol.ttf +0 -0
  173. matplotlib_rs/mpl-data/fonts/ttf/STIXSizFourSymReg.ttf +0 -0
  174. matplotlib_rs/mpl-data/fonts/ttf/STIXSizOneSymBol.ttf +0 -0
  175. matplotlib_rs/mpl-data/fonts/ttf/STIXSizOneSymReg.ttf +0 -0
  176. matplotlib_rs/mpl-data/fonts/ttf/STIXSizThreeSymBol.ttf +0 -0
  177. matplotlib_rs/mpl-data/fonts/ttf/STIXSizThreeSymReg.ttf +0 -0
  178. matplotlib_rs/mpl-data/fonts/ttf/STIXSizTwoSymBol.ttf +0 -0
  179. matplotlib_rs/mpl-data/fonts/ttf/STIXSizTwoSymReg.ttf +0 -0
  180. matplotlib_rs/mpl-data/fonts/ttf/cmb10.ttf +0 -0
  181. matplotlib_rs/mpl-data/fonts/ttf/cmex10.ttf +0 -0
  182. matplotlib_rs/mpl-data/fonts/ttf/cmmi10.ttf +0 -0
  183. matplotlib_rs/mpl-data/fonts/ttf/cmr10.ttf +0 -0
  184. matplotlib_rs/mpl-data/fonts/ttf/cmss10.ttf +0 -0
  185. matplotlib_rs/mpl-data/fonts/ttf/cmsy10.ttf +0 -0
  186. matplotlib_rs/mpl-data/fonts/ttf/cmti10.ttf +0 -0
  187. matplotlib_rs/mpl-data/fonts/ttf/cmtt10.ttf +0 -0
  188. matplotlib_rs/mpl-data/images/back-symbolic.svg +46 -0
  189. matplotlib_rs/mpl-data/images/back.pdf +0 -0
  190. matplotlib_rs/mpl-data/images/back.png +0 -0
  191. matplotlib_rs/mpl-data/images/back.svg +46 -0
  192. matplotlib_rs/mpl-data/images/back_large.png +0 -0
  193. matplotlib_rs/mpl-data/images/filesave-symbolic.svg +68 -0
  194. matplotlib_rs/mpl-data/images/filesave.pdf +72 -0
  195. matplotlib_rs/mpl-data/images/filesave.png +0 -0
  196. matplotlib_rs/mpl-data/images/filesave.svg +68 -0
  197. matplotlib_rs/mpl-data/images/filesave_large.png +0 -0
  198. matplotlib_rs/mpl-data/images/forward-symbolic.svg +46 -0
  199. matplotlib_rs/mpl-data/images/forward.pdf +0 -0
  200. matplotlib_rs/mpl-data/images/forward.png +0 -0
  201. matplotlib_rs/mpl-data/images/forward.svg +46 -0
  202. matplotlib_rs/mpl-data/images/forward_large.png +0 -0
  203. matplotlib_rs/mpl-data/images/hand.pdf +0 -0
  204. matplotlib_rs/mpl-data/images/hand.png +0 -0
  205. matplotlib_rs/mpl-data/images/hand.svg +130 -0
  206. matplotlib_rs/mpl-data/images/help-symbolic.svg +52 -0
  207. matplotlib_rs/mpl-data/images/help.pdf +71 -0
  208. matplotlib_rs/mpl-data/images/help.png +0 -0
  209. matplotlib_rs/mpl-data/images/help.svg +52 -0
  210. matplotlib_rs/mpl-data/images/help_large.png +0 -0
  211. matplotlib_rs/mpl-data/images/home-symbolic.svg +59 -0
  212. matplotlib_rs/mpl-data/images/home.pdf +0 -0
  213. matplotlib_rs/mpl-data/images/home.png +0 -0
  214. matplotlib_rs/mpl-data/images/home.svg +59 -0
  215. matplotlib_rs/mpl-data/images/home_large.png +0 -0
  216. matplotlib_rs/mpl-data/images/matplotlib.pdf +0 -0
  217. matplotlib_rs/mpl-data/images/matplotlib.png +0 -0
  218. matplotlib_rs/mpl-data/images/matplotlib.svg +3171 -0
  219. matplotlib_rs/mpl-data/images/matplotlib_large.png +0 -0
  220. matplotlib_rs/mpl-data/images/move-symbolic.svg +73 -0
  221. matplotlib_rs/mpl-data/images/move.pdf +0 -0
  222. matplotlib_rs/mpl-data/images/move.png +0 -0
  223. matplotlib_rs/mpl-data/images/move.svg +73 -0
  224. matplotlib_rs/mpl-data/images/move_large.png +0 -0
  225. matplotlib_rs/mpl-data/images/qt4_editor_options.pdf +0 -0
  226. matplotlib_rs/mpl-data/images/qt4_editor_options.png +0 -0
  227. matplotlib_rs/mpl-data/images/qt4_editor_options.svg +48 -0
  228. matplotlib_rs/mpl-data/images/qt4_editor_options_large.png +0 -0
  229. matplotlib_rs/mpl-data/images/subplots-symbolic.svg +81 -0
  230. matplotlib_rs/mpl-data/images/subplots.pdf +0 -0
  231. matplotlib_rs/mpl-data/images/subplots.png +0 -0
  232. matplotlib_rs/mpl-data/images/subplots.svg +81 -0
  233. matplotlib_rs/mpl-data/images/subplots_large.png +0 -0
  234. matplotlib_rs/mpl-data/images/zoom_to_rect-symbolic.svg +40 -0
  235. matplotlib_rs/mpl-data/images/zoom_to_rect.pdf +69 -0
  236. matplotlib_rs/mpl-data/images/zoom_to_rect.png +0 -0
  237. matplotlib_rs/mpl-data/images/zoom_to_rect.svg +40 -0
  238. matplotlib_rs/mpl-data/images/zoom_to_rect_large.png +0 -0
  239. matplotlib_rs/mpl-data/kpsewhich.lua +4 -0
  240. matplotlib_rs/mpl-data/matplotlibrc +849 -0
  241. matplotlib_rs/mpl-data/plot_directive/plot_directive.css +16 -0
  242. matplotlib_rs/mpl-data/sample_data/Minduka_Present_Blue_Pack.png +0 -0
  243. matplotlib_rs/mpl-data/sample_data/README.txt +2 -0
  244. matplotlib_rs/mpl-data/sample_data/Stocks.csv +526 -0
  245. matplotlib_rs/mpl-data/sample_data/axes_grid/bivariate_normal.npy +0 -0
  246. matplotlib_rs/mpl-data/sample_data/data_x_x2_x3.csv +11 -0
  247. matplotlib_rs/mpl-data/sample_data/eeg.dat +0 -0
  248. matplotlib_rs/mpl-data/sample_data/embedding_in_wx3.xrc +65 -0
  249. matplotlib_rs/mpl-data/sample_data/goog.npz +0 -0
  250. matplotlib_rs/mpl-data/sample_data/grace_hopper.jpg +0 -0
  251. matplotlib_rs/mpl-data/sample_data/jacksboro_fault_dem.npz +0 -0
  252. matplotlib_rs/mpl-data/sample_data/logo2.png +0 -0
  253. matplotlib_rs/mpl-data/sample_data/membrane.dat +0 -0
  254. matplotlib_rs/mpl-data/sample_data/msft.csv +66 -0
  255. matplotlib_rs/mpl-data/sample_data/s1045.ima.gz +0 -0
  256. matplotlib_rs/mpl-data/sample_data/topobathy.npz +0 -0
  257. matplotlib_rs/mpl-data/stylelib/Solarize_Light2.mplstyle +53 -0
  258. matplotlib_rs/mpl-data/stylelib/_classic_test_patch.mplstyle +8 -0
  259. matplotlib_rs/mpl-data/stylelib/_mpl-gallery-nogrid.mplstyle +19 -0
  260. matplotlib_rs/mpl-data/stylelib/_mpl-gallery.mplstyle +19 -0
  261. matplotlib_rs/mpl-data/stylelib/bmh.mplstyle +27 -0
  262. matplotlib_rs/mpl-data/stylelib/classic.mplstyle +491 -0
  263. matplotlib_rs/mpl-data/stylelib/dark_background.mplstyle +26 -0
  264. matplotlib_rs/mpl-data/stylelib/fast.mplstyle +11 -0
  265. matplotlib_rs/mpl-data/stylelib/fivethirtyeight.mplstyle +37 -0
  266. matplotlib_rs/mpl-data/stylelib/ggplot.mplstyle +39 -0
  267. matplotlib_rs/mpl-data/stylelib/grayscale.mplstyle +29 -0
  268. matplotlib_rs/mpl-data/stylelib/petroff10.mplstyle +5 -0
  269. matplotlib_rs/mpl-data/stylelib/petroff6.mplstyle +5 -0
  270. matplotlib_rs/mpl-data/stylelib/petroff8.mplstyle +5 -0
  271. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-bright.mplstyle +3 -0
  272. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-colorblind.mplstyle +3 -0
  273. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-dark-palette.mplstyle +3 -0
  274. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-dark.mplstyle +30 -0
  275. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-darkgrid.mplstyle +30 -0
  276. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-deep.mplstyle +3 -0
  277. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-muted.mplstyle +3 -0
  278. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-notebook.mplstyle +21 -0
  279. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-paper.mplstyle +21 -0
  280. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-pastel.mplstyle +3 -0
  281. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-poster.mplstyle +21 -0
  282. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-talk.mplstyle +21 -0
  283. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-ticks.mplstyle +30 -0
  284. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-white.mplstyle +30 -0
  285. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-whitegrid.mplstyle +30 -0
  286. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8.mplstyle +57 -0
  287. matplotlib_rs/mpl-data/stylelib/tableau-colorblind10.mplstyle +3 -0
  288. matplotlib_rs/mpl_toolkits/__init__.py +3 -0
  289. matplotlib_rs/mpl_toolkits/axes_grid1/__init__.py +11 -0
  290. matplotlib_rs/mpl_toolkits/axes_grid1/anchored_artists.py +415 -0
  291. matplotlib_rs/mpl_toolkits/axes_grid1/axes_divider.py +619 -0
  292. matplotlib_rs/mpl_toolkits/axes_grid1/axes_grid.py +565 -0
  293. matplotlib_rs/mpl_toolkits/axes_grid1/axes_rgb.py +158 -0
  294. matplotlib_rs/mpl_toolkits/axes_grid1/axes_size.py +272 -0
  295. matplotlib_rs/mpl_toolkits/axes_grid1/inset_locator.py +525 -0
  296. matplotlib_rs/mpl_toolkits/axes_grid1/mpl_axes.py +129 -0
  297. matplotlib_rs/mpl_toolkits/axes_grid1/parasite_axes.py +261 -0
  298. matplotlib_rs/mpl_toolkits/axisartist/__init__.py +15 -0
  299. matplotlib_rs/mpl_toolkits/axisartist/angle_helper.py +396 -0
  300. matplotlib_rs/mpl_toolkits/axisartist/axes_divider.py +3 -0
  301. matplotlib_rs/mpl_toolkits/axisartist/axis_artist.py +1148 -0
  302. matplotlib_rs/mpl_toolkits/axisartist/axisline_style.py +193 -0
  303. matplotlib_rs/mpl_toolkits/axisartist/axislines.py +475 -0
  304. matplotlib_rs/mpl_toolkits/axisartist/floating_axes.py +265 -0
  305. matplotlib_rs/mpl_toolkits/axisartist/grid_finder.py +329 -0
  306. matplotlib_rs/mpl_toolkits/axisartist/grid_helper_curvelinear.py +353 -0
  307. matplotlib_rs/mpl_toolkits/axisartist/parasite_axes.py +8 -0
  308. matplotlib_rs/mpl_toolkits/mplot3d/__init__.py +4 -0
  309. matplotlib_rs/mpl_toolkits/mplot3d/art3d.py +1758 -0
  310. matplotlib_rs/mpl_toolkits/mplot3d/axes3d.py +4462 -0
  311. matplotlib_rs/mpl_toolkits/mplot3d/axis3d.py +807 -0
  312. matplotlib_rs/mpl_toolkits/mplot3d/proj3d.py +270 -0
  313. matplotlib_rs/offsetbox.py +1726 -0
  314. matplotlib_rs/patches.py +5049 -0
  315. matplotlib_rs/path.py +1147 -0
  316. matplotlib_rs/patheffects.py +512 -0
  317. matplotlib_rs/projections/__init__.py +126 -0
  318. matplotlib_rs/projections/geo.py +512 -0
  319. matplotlib_rs/projections/polar.py +1518 -0
  320. matplotlib_rs/pylab.py +68 -0
  321. matplotlib_rs/pyplot.py +4834 -0
  322. matplotlib_rs/quiver.py +1236 -0
  323. matplotlib_rs/rcsetup.py +3435 -0
  324. matplotlib_rs/sankey.py +815 -0
  325. matplotlib_rs/scale.py +1002 -0
  326. matplotlib_rs/spines.py +618 -0
  327. matplotlib_rs/stackplot.py +144 -0
  328. matplotlib_rs/streamplot.py +768 -0
  329. matplotlib_rs/style/__init__.py +269 -0
  330. matplotlib_rs/style/core.py +28 -0
  331. matplotlib_rs/table.py +860 -0
  332. matplotlib_rs/texmanager.py +375 -0
  333. matplotlib_rs/text.py +2412 -0
  334. matplotlib_rs/textpath.py +377 -0
  335. matplotlib_rs/ticker.py +3111 -0
  336. matplotlib_rs/transforms.py +3069 -0
  337. matplotlib_rs/tri/__init__.py +24 -0
  338. matplotlib_rs/tri/_triangulation.py +248 -0
  339. matplotlib_rs/tri/_tricontour.py +271 -0
  340. matplotlib_rs/tri/_trifinder.py +97 -0
  341. matplotlib_rs/tri/_triinterpolate.py +1575 -0
  342. matplotlib_rs/tri/_tripcolor.py +170 -0
  343. matplotlib_rs/tri/_triplot.py +87 -0
  344. matplotlib_rs/tri/_trirefine.py +308 -0
  345. matplotlib_rs/tri/_tritools.py +264 -0
  346. matplotlib_rs/typing.py +597 -0
  347. matplotlib_rs/units.py +196 -0
  348. matplotlib_rs/widgets.py +4455 -0
  349. matplotlib_rs-0.0.8.dist-info/METADATA +392 -0
  350. matplotlib_rs-0.0.8.dist-info/RECORD +352 -0
  351. matplotlib_rs-0.0.8.dist-info/WHEEL +4 -0
  352. matplotlib_rs-0.0.8.dist-info/sboms/matplotlib-rs.cyclonedx.json +4390 -0
@@ -0,0 +1,1002 @@
1
+ # Vendored from matplotlib 3.11 (see licenses/LICENSE_MATPLOTLIB), adapted for matplotlib_rs.
2
+ """
3
+ Abstract base classes define the primitives for Tools.
4
+ These tools are used by `matplotlib.backend_managers.ToolManager`
5
+
6
+ :class:`ToolBase`
7
+ Simple stateless tool
8
+
9
+ :class:`ToolToggleBase`
10
+ Tool that has two states, only one Toggle tool can be
11
+ active at any given time for the same
12
+ `matplotlib.backend_managers.ToolManager`
13
+ """
14
+
15
+ import enum
16
+ import functools
17
+ import re
18
+ import time
19
+ from types import SimpleNamespace
20
+ import uuid
21
+ from weakref import WeakKeyDictionary
22
+
23
+ import numpy as np
24
+
25
+ import matplotlib_rs as mpl
26
+ from matplotlib_rs._pylab_helpers import Gcf
27
+ from matplotlib_rs import _api, cbook
28
+
29
+
30
+ class Cursors(enum.IntEnum): # Must subclass int for the macOS backend.
31
+ """Backend-independent cursor types."""
32
+ POINTER = enum.auto()
33
+ HAND = enum.auto()
34
+ SELECT_REGION = enum.auto()
35
+ MOVE = enum.auto()
36
+ WAIT = enum.auto()
37
+ RESIZE_HORIZONTAL = enum.auto()
38
+ RESIZE_VERTICAL = enum.auto()
39
+ cursors = Cursors # Backcompat.
40
+
41
+
42
+ # _tool_registry, _register_tool_class, and _find_tool_class implement a
43
+ # mechanism through which ToolManager.add_tool can determine whether a subclass
44
+ # of the requested tool class has been registered (either for the current
45
+ # canvas class or for a parent class), in which case that tool subclass will be
46
+ # instantiated instead. This is the mechanism used e.g. to allow different
47
+ # GUI backends to implement different specializations for ConfigureSubplots.
48
+
49
+
50
+ _tool_registry = set()
51
+
52
+
53
+ def _register_tool_class(canvas_cls, tool_cls=None):
54
+ """Decorator registering *tool_cls* as a tool class for *canvas_cls*."""
55
+ if tool_cls is None:
56
+ return functools.partial(_register_tool_class, canvas_cls)
57
+ _tool_registry.add((canvas_cls, tool_cls))
58
+ return tool_cls
59
+
60
+
61
+ def _find_tool_class(canvas_cls, tool_cls):
62
+ """Find a subclass of *tool_cls* registered for *canvas_cls*."""
63
+ for canvas_parent in canvas_cls.__mro__:
64
+ for tool_child in _api.recursive_subclasses(tool_cls):
65
+ if (canvas_parent, tool_child) in _tool_registry:
66
+ return tool_child
67
+ return tool_cls
68
+
69
+
70
+ # Views positions tool
71
+ _views_positions = 'viewpos'
72
+
73
+
74
+ class ToolBase:
75
+ """
76
+ Base tool class.
77
+
78
+ A base tool, only implements `trigger` method or no method at all.
79
+ The tool is instantiated by `matplotlib.backend_managers.ToolManager`.
80
+ """
81
+
82
+ default_keymap = None
83
+ """
84
+ Keymap to associate with this tool.
85
+
86
+ ``list[str]``: List of keys that will trigger this tool when a keypress
87
+ event is emitted on ``self.figure.canvas``. Note that this attribute is
88
+ looked up on the instance, and can therefore be a property (this is used
89
+ e.g. by the built-in tools to load the rcParams at instantiation time).
90
+ """
91
+
92
+ description = None
93
+ """
94
+ Description of the Tool.
95
+
96
+ `str`: Tooltip used if the Tool is included in a Toolbar.
97
+ """
98
+
99
+ image = None
100
+ """
101
+ Icon filename.
102
+
103
+ ``str | None``: Filename of the Toolbar icon; either absolute, or relative to the
104
+ directory containing the Python source file where the ``Tool.image`` class attribute
105
+ is defined (in the latter case, this cannot be defined as an instance attribute).
106
+ In either case, the extension is optional; leaving it off lets individual backends
107
+ select the icon format they prefer. If None, the *name* is used as a label in the
108
+ toolbar button.
109
+ """
110
+
111
+ def __init__(self, toolmanager, name):
112
+ self._name = name
113
+ self._toolmanager = toolmanager
114
+ self._figure = None
115
+
116
+ name = property(
117
+ lambda self: self._name,
118
+ doc="The tool id (str, must be unique among tools of a tool manager).")
119
+ toolmanager = property(
120
+ lambda self: self._toolmanager,
121
+ doc="The `.ToolManager` that controls this tool.")
122
+ canvas = property(
123
+ lambda self: self._figure.canvas if self._figure is not None else None,
124
+ doc="The canvas of the figure affected by this tool, or None.")
125
+
126
+ def set_figure(self, figure):
127
+ self._figure = figure
128
+
129
+ figure = property(
130
+ lambda self: self._figure,
131
+ # The setter must explicitly call self.set_figure so that subclasses can
132
+ # meaningfully override it.
133
+ lambda self, figure: self.set_figure(figure),
134
+ doc="The Figure affected by this tool, or None.")
135
+
136
+ def _make_classic_style_pseudo_toolbar(self):
137
+ """
138
+ Return a placeholder object with a single `canvas` attribute.
139
+
140
+ This is useful to reuse the implementations of tools already provided
141
+ by the classic Toolbars.
142
+ """
143
+ return SimpleNamespace(canvas=self.canvas)
144
+
145
+ def trigger(self, sender, event, data=None):
146
+ """
147
+ Called when this tool gets used.
148
+
149
+ This method is called by `.ToolManager.trigger_tool`.
150
+
151
+ Parameters
152
+ ----------
153
+ event : `.Event`
154
+ The canvas event that caused this tool to be called.
155
+ sender : object
156
+ Object that requested the tool to be triggered.
157
+ data : object
158
+ Extra data.
159
+ """
160
+ pass
161
+
162
+
163
+ class ToolToggleBase(ToolBase):
164
+ """
165
+ Toggleable tool.
166
+
167
+ Every time it is triggered, it switches between enable and disable.
168
+
169
+ Parameters
170
+ ----------
171
+ ``*args``
172
+ Variable length argument to be used by the Tool.
173
+ ``**kwargs``
174
+ `toggled` if present and True, sets the initial state of the Tool
175
+ Arbitrary keyword arguments to be consumed by the Tool
176
+ """
177
+
178
+ radio_group = None
179
+ """
180
+ Attribute to group 'radio' like tools (mutually exclusive).
181
+
182
+ `str` that identifies the group or **None** if not belonging to a group.
183
+ """
184
+
185
+ cursor = None
186
+ """Cursor to use when the tool is active."""
187
+
188
+ default_toggled = False
189
+ """Default of toggled state."""
190
+
191
+ def __init__(self, *args, **kwargs):
192
+ self._toggled = kwargs.pop('toggled', self.default_toggled)
193
+ super().__init__(*args, **kwargs)
194
+
195
+ def trigger(self, sender, event, data=None):
196
+ """Calls `enable` or `disable` based on `~ToolToggleBase.toggled` value."""
197
+ if self._toggled:
198
+ self.disable(event)
199
+ else:
200
+ self.enable(event)
201
+ self._toggled = not self._toggled
202
+
203
+ def enable(self, event=None):
204
+ """
205
+ Enable the toggle tool.
206
+
207
+ `trigger` calls this method when `~ToolToggleBase.toggled` is False.
208
+ """
209
+ pass
210
+
211
+ def disable(self, event=None):
212
+ """
213
+ Disable the toggle tool.
214
+
215
+ `trigger` call this method when `~ToolToggleBase.toggled` is True.
216
+
217
+ This can happen in different circumstances.
218
+
219
+ * Click on the toolbar tool button.
220
+ * Call to `matplotlib.backend_managers.ToolManager.trigger_tool`.
221
+ * Another `ToolToggleBase` derived tool is triggered
222
+ (from the same `.ToolManager`).
223
+ """
224
+ pass
225
+
226
+ @property
227
+ def toggled(self):
228
+ """State of the toggled tool."""
229
+ return self._toggled
230
+
231
+ def set_figure(self, figure):
232
+ toggled = self.toggled
233
+ if toggled:
234
+ if self.figure:
235
+ self.trigger(self, None)
236
+ else:
237
+ # if no figure the internal state is not changed
238
+ # we change it here so next call to trigger will change it back
239
+ self._toggled = False
240
+ super().set_figure(figure)
241
+ if toggled:
242
+ if figure:
243
+ self.trigger(self, None)
244
+ else:
245
+ # if there is no figure, trigger won't change the internal
246
+ # state we change it back
247
+ self._toggled = True
248
+
249
+
250
+ class ToolSetCursor(ToolBase):
251
+ """
252
+ Change to the current cursor while inaxes.
253
+
254
+ This tool, keeps track of all `ToolToggleBase` derived tools, and updates
255
+ the cursor when a tool gets triggered.
256
+ """
257
+ def __init__(self, *args, **kwargs):
258
+ super().__init__(*args, **kwargs)
259
+ self._id_drag = None
260
+ self._current_tool = None
261
+ self._default_cursor = cursors.POINTER
262
+ self._last_cursor = self._default_cursor
263
+ self.toolmanager.toolmanager_connect('tool_added_event',
264
+ self._add_tool_cbk)
265
+ for tool in self.toolmanager.tools.values(): # process current tools
266
+ self._add_tool_cbk(mpl.backend_managers.ToolEvent(
267
+ 'tool_added_event', self.toolmanager, tool))
268
+
269
+ def set_figure(self, figure):
270
+ if self._id_drag:
271
+ self.canvas.mpl_disconnect(self._id_drag)
272
+ super().set_figure(figure)
273
+ if figure:
274
+ self._id_drag = self.canvas.mpl_connect(
275
+ 'motion_notify_event', self._set_cursor_cbk)
276
+
277
+ def _add_tool_cbk(self, event):
278
+ """Process every newly added tool."""
279
+ if getattr(event.tool, 'cursor', None) is not None:
280
+ self.toolmanager.toolmanager_connect(
281
+ f'tool_trigger_{event.tool.name}', self._tool_trigger_cbk)
282
+
283
+ def _tool_trigger_cbk(self, event):
284
+ self._current_tool = event.tool if event.tool.toggled else None
285
+ self._set_cursor_cbk(event.canvasevent)
286
+
287
+ def _set_cursor_cbk(self, event):
288
+ if not event or not self.canvas:
289
+ return
290
+ if (self._current_tool and getattr(event, "inaxes", None)
291
+ and event.inaxes.get_navigate()):
292
+ if self._last_cursor != self._current_tool.cursor:
293
+ self.canvas.set_cursor(self._current_tool.cursor)
294
+ self._last_cursor = self._current_tool.cursor
295
+ elif self._last_cursor != self._default_cursor:
296
+ self.canvas.set_cursor(self._default_cursor)
297
+ self._last_cursor = self._default_cursor
298
+
299
+
300
+ class ToolCursorPosition(ToolBase):
301
+ """
302
+ Send message with the current pointer position.
303
+
304
+ This tool runs in the background reporting the position of the cursor.
305
+ """
306
+ def __init__(self, *args, **kwargs):
307
+ self._id_drag = None
308
+ super().__init__(*args, **kwargs)
309
+
310
+ def set_figure(self, figure):
311
+ if self._id_drag:
312
+ self.canvas.mpl_disconnect(self._id_drag)
313
+ super().set_figure(figure)
314
+ if figure:
315
+ self._id_drag = self.canvas.mpl_connect(
316
+ 'motion_notify_event', self.send_message)
317
+
318
+ def send_message(self, event):
319
+ """Call `matplotlib.backend_managers.ToolManager.message_event`."""
320
+ if self.toolmanager.messagelock.locked():
321
+ return
322
+
323
+ from matplotlib_rs.backend_bases import NavigationToolbar2
324
+ message = NavigationToolbar2._mouse_event_to_message(event)
325
+ self.toolmanager.message_event(message, self)
326
+
327
+
328
+ class RubberbandBase(ToolBase):
329
+ """Draw and remove a rubberband."""
330
+ def trigger(self, sender, event, data=None):
331
+ """Call `draw_rubberband` or `remove_rubberband` based on data."""
332
+ if not self.figure.canvas.widgetlock.available(sender):
333
+ return
334
+ if data is not None:
335
+ self.draw_rubberband(*data)
336
+ else:
337
+ self.remove_rubberband()
338
+
339
+ def draw_rubberband(self, *data):
340
+ """
341
+ Draw rubberband.
342
+
343
+ This method must get implemented per backend.
344
+ """
345
+ raise NotImplementedError
346
+
347
+ def remove_rubberband(self):
348
+ """
349
+ Remove rubberband.
350
+
351
+ This method should get implemented per backend.
352
+ """
353
+ pass
354
+
355
+
356
+ class ToolQuit(ToolBase):
357
+ """Tool to call the figure manager destroy method."""
358
+
359
+ description = 'Quit the figure'
360
+ default_keymap = property(lambda self: mpl.rcParams['keymap.quit'])
361
+
362
+ def trigger(self, sender, event, data=None):
363
+ Gcf.destroy_fig(self.figure)
364
+
365
+
366
+ class ToolQuitAll(ToolBase):
367
+ """Tool to call the figure manager destroy method."""
368
+
369
+ description = 'Quit all figures'
370
+ default_keymap = property(lambda self: mpl.rcParams['keymap.quit_all'])
371
+
372
+ def trigger(self, sender, event, data=None):
373
+ Gcf.destroy_all()
374
+
375
+
376
+ class ToolGrid(ToolBase):
377
+ """Tool to toggle the major grids of the figure."""
378
+
379
+ description = 'Toggle major grids'
380
+ default_keymap = property(lambda self: mpl.rcParams['keymap.grid'])
381
+
382
+ def trigger(self, sender, event, data=None):
383
+ sentinel = str(uuid.uuid4())
384
+ # Trigger grid switching by temporarily setting :rc:`keymap.grid`
385
+ # to a unique key and sending an appropriate event.
386
+ with (cbook._setattr_cm(event, key=sentinel),
387
+ mpl.rc_context({'keymap.grid': sentinel})):
388
+ mpl.backend_bases.key_press_handler(event, self.figure.canvas)
389
+
390
+
391
+ class ToolMinorGrid(ToolBase):
392
+ """Tool to toggle the major and minor grids of the figure."""
393
+
394
+ description = 'Toggle major and minor grids'
395
+ default_keymap = property(lambda self: mpl.rcParams['keymap.grid_minor'])
396
+
397
+ def trigger(self, sender, event, data=None):
398
+ sentinel = str(uuid.uuid4())
399
+ # Trigger grid switching by temporarily setting :rc:`keymap.grid_minor`
400
+ # to a unique key and sending an appropriate event.
401
+ with (cbook._setattr_cm(event, key=sentinel),
402
+ mpl.rc_context({'keymap.grid_minor': sentinel})):
403
+ mpl.backend_bases.key_press_handler(event, self.figure.canvas)
404
+
405
+
406
+ class ToolFullScreen(ToolBase):
407
+ """Tool to toggle full screen."""
408
+
409
+ description = 'Toggle fullscreen mode'
410
+ default_keymap = property(lambda self: mpl.rcParams['keymap.fullscreen'])
411
+
412
+ def trigger(self, sender, event, data=None):
413
+ self.figure.canvas.manager.full_screen_toggle()
414
+
415
+
416
+ class AxisScaleBase(ToolToggleBase):
417
+ """Base Tool to toggle between linear and logarithmic."""
418
+
419
+ def trigger(self, sender, event, data=None):
420
+ if event.inaxes is None:
421
+ return
422
+ super().trigger(sender, event, data)
423
+
424
+ def enable(self, event=None):
425
+ self.set_scale(event.inaxes, 'log')
426
+ self.figure.canvas.draw_idle()
427
+
428
+ def disable(self, event=None):
429
+ self.set_scale(event.inaxes, 'linear')
430
+ self.figure.canvas.draw_idle()
431
+
432
+
433
+ class ToolYScale(AxisScaleBase):
434
+ """Tool to toggle between linear and logarithmic scales on the Y axis."""
435
+
436
+ description = 'Toggle scale Y axis'
437
+ default_keymap = property(lambda self: mpl.rcParams['keymap.yscale'])
438
+
439
+ def set_scale(self, ax, scale):
440
+ ax.set_yscale(scale)
441
+
442
+
443
+ class ToolXScale(AxisScaleBase):
444
+ """Tool to toggle between linear and logarithmic scales on the X axis."""
445
+
446
+ description = 'Toggle scale X axis'
447
+ default_keymap = property(lambda self: mpl.rcParams['keymap.xscale'])
448
+
449
+ def set_scale(self, ax, scale):
450
+ ax.set_xscale(scale)
451
+
452
+
453
+ class ToolViewsPositions(ToolBase):
454
+ """
455
+ Auxiliary Tool to handle changes in views and positions.
456
+
457
+ Runs in the background and should get used by all the tools that
458
+ need to access the figure's history of views and positions, e.g.
459
+
460
+ * `ToolZoom`
461
+ * `ToolPan`
462
+ * `ToolHome`
463
+ * `ToolBack`
464
+ * `ToolForward`
465
+ """
466
+
467
+ def __init__(self, *args, **kwargs):
468
+ self.views = WeakKeyDictionary()
469
+ self.positions = WeakKeyDictionary()
470
+ self.home_views = WeakKeyDictionary()
471
+ super().__init__(*args, **kwargs)
472
+
473
+ def add_figure(self, figure):
474
+ """Add the current figure to the stack of views and positions."""
475
+
476
+ if figure not in self.views:
477
+ self.views[figure] = cbook._Stack()
478
+ self.positions[figure] = cbook._Stack()
479
+ self.home_views[figure] = WeakKeyDictionary()
480
+ # Define Home
481
+ self.push_current(figure)
482
+ # Make sure we add a home view for new Axes as they're added
483
+ figure.add_axobserver(lambda fig: self.update_home_views(fig))
484
+
485
+ def clear(self, figure):
486
+ """Reset the Axes stack."""
487
+ if figure in self.views:
488
+ self.views[figure].clear()
489
+ self.positions[figure].clear()
490
+ self.home_views[figure].clear()
491
+ self.update_home_views()
492
+
493
+ def update_view(self):
494
+ """
495
+ Update the view limits and position for each Axes from the current
496
+ stack position. If any Axes are present in the figure that aren't in
497
+ the current stack position, use the home view limits for those Axes and
498
+ don't update *any* positions.
499
+ """
500
+
501
+ views = self.views[self.figure]()
502
+ if views is None:
503
+ return
504
+ pos = self.positions[self.figure]()
505
+ if pos is None:
506
+ return
507
+ home_views = self.home_views[self.figure]
508
+ all_axes = self.figure.get_axes()
509
+ for a in all_axes:
510
+ if a in views:
511
+ cur_view = views[a]
512
+ else:
513
+ cur_view = home_views[a]
514
+ a._set_view(cur_view)
515
+
516
+ if set(all_axes).issubset(pos):
517
+ for a in all_axes:
518
+ # Restore both the original and modified positions
519
+ a._set_position(pos[a][0], 'original')
520
+ a._set_position(pos[a][1], 'active')
521
+
522
+ self.figure.canvas.draw_idle()
523
+
524
+ def push_current(self, figure=None):
525
+ """
526
+ Push the current view limits and position onto their respective stacks.
527
+ """
528
+ if not figure:
529
+ figure = self.figure
530
+ views = WeakKeyDictionary()
531
+ pos = WeakKeyDictionary()
532
+ for a in figure.get_axes():
533
+ views[a] = a._get_view()
534
+ pos[a] = self._axes_pos(a)
535
+ self.views[figure].push(views)
536
+ self.positions[figure].push(pos)
537
+
538
+ def _axes_pos(self, ax):
539
+ """
540
+ Return the original and modified positions for the specified Axes.
541
+
542
+ Parameters
543
+ ----------
544
+ ax : matplotlib.axes.Axes
545
+ The `.Axes` to get the positions for.
546
+
547
+ Returns
548
+ -------
549
+ original_position, modified_position
550
+ A tuple of the original and modified positions.
551
+ """
552
+
553
+ return (ax.get_position(True).frozen(),
554
+ ax.get_position().frozen())
555
+
556
+ def update_home_views(self, figure=None):
557
+ """
558
+ Make sure that ``self.home_views`` has an entry for all Axes present
559
+ in the figure.
560
+ """
561
+
562
+ if not figure:
563
+ figure = self.figure
564
+ for a in figure.get_axes():
565
+ if a not in self.home_views[figure]:
566
+ self.home_views[figure][a] = a._get_view()
567
+
568
+ def home(self):
569
+ """Recall the first view and position from the stack."""
570
+ self.views[self.figure].home()
571
+ self.positions[self.figure].home()
572
+
573
+ def back(self):
574
+ """Back one step in the stack of views and positions."""
575
+ self.views[self.figure].back()
576
+ self.positions[self.figure].back()
577
+
578
+ def forward(self):
579
+ """Forward one step in the stack of views and positions."""
580
+ self.views[self.figure].forward()
581
+ self.positions[self.figure].forward()
582
+
583
+
584
+ class ViewsPositionsBase(ToolBase):
585
+ """Base class for `ToolHome`, `ToolBack` and `ToolForward`."""
586
+
587
+ _on_trigger = None
588
+
589
+ def trigger(self, sender, event, data=None):
590
+ self.toolmanager.get_tool(_views_positions).add_figure(self.figure)
591
+ getattr(self.toolmanager.get_tool(_views_positions),
592
+ self._on_trigger)()
593
+ self.toolmanager.get_tool(_views_positions).update_view()
594
+
595
+
596
+ class ToolHome(ViewsPositionsBase):
597
+ """Restore the original view limits."""
598
+
599
+ description = 'Reset original view'
600
+ image = 'mpl-data/images/home'
601
+ default_keymap = property(lambda self: mpl.rcParams['keymap.home'])
602
+ _on_trigger = 'home'
603
+
604
+
605
+ class ToolBack(ViewsPositionsBase):
606
+ """Move back up the view limits stack."""
607
+
608
+ description = 'Back to previous view'
609
+ image = 'mpl-data/images/back'
610
+ default_keymap = property(lambda self: mpl.rcParams['keymap.back'])
611
+ _on_trigger = 'back'
612
+
613
+
614
+ class ToolForward(ViewsPositionsBase):
615
+ """Move forward in the view lim stack."""
616
+
617
+ description = 'Forward to next view'
618
+ image = 'mpl-data/images/forward'
619
+ default_keymap = property(lambda self: mpl.rcParams['keymap.forward'])
620
+ _on_trigger = 'forward'
621
+
622
+
623
+ class ConfigureSubplotsBase(ToolBase):
624
+ """Base tool for the configuration of subplots."""
625
+
626
+ description = 'Configure subplots'
627
+ image = 'mpl-data/images/subplots'
628
+
629
+
630
+ class SaveFigureBase(ToolBase):
631
+ """Base tool for figure saving."""
632
+
633
+ description = 'Save the figure'
634
+ image = 'mpl-data/images/filesave'
635
+ default_keymap = property(lambda self: mpl.rcParams['keymap.save'])
636
+
637
+
638
+ class ZoomPanBase(ToolToggleBase):
639
+ """Base class for `ToolZoom` and `ToolPan`."""
640
+ def __init__(self, *args):
641
+ super().__init__(*args)
642
+ self._button_pressed = None
643
+ self._xypress = None
644
+ self._idPress = None
645
+ self._idRelease = None
646
+ self._idScroll = None
647
+ self.base_scale = 2.
648
+ self.scrollthresh = .5 # .5 second scroll threshold
649
+ self.lastscroll = time.time()-self.scrollthresh
650
+
651
+ def enable(self, event=None):
652
+ """Connect press/release events and lock the canvas."""
653
+ self.figure.canvas.widgetlock(self)
654
+ self._idPress = self.figure.canvas.mpl_connect(
655
+ 'button_press_event', self._press)
656
+ self._idRelease = self.figure.canvas.mpl_connect(
657
+ 'button_release_event', self._release)
658
+ self._idScroll = self.figure.canvas.mpl_connect(
659
+ 'scroll_event', self.scroll_zoom)
660
+
661
+ def disable(self, event=None):
662
+ """Release the canvas and disconnect press/release events."""
663
+ self._cancel_action()
664
+ self.figure.canvas.widgetlock.release(self)
665
+ self.figure.canvas.mpl_disconnect(self._idPress)
666
+ self.figure.canvas.mpl_disconnect(self._idRelease)
667
+ self.figure.canvas.mpl_disconnect(self._idScroll)
668
+
669
+ def trigger(self, sender, event, data=None):
670
+ self.toolmanager.get_tool(_views_positions).add_figure(self.figure)
671
+ super().trigger(sender, event, data)
672
+
673
+ def scroll_zoom(self, event):
674
+ # https://gist.github.com/tacaswell/3144287
675
+ if event.inaxes is None:
676
+ return
677
+
678
+ if event.button == 'up':
679
+ # deal with zoom in
680
+ scl = self.base_scale
681
+ elif event.button == 'down':
682
+ # deal with zoom out
683
+ scl = 1/self.base_scale
684
+ else:
685
+ # deal with something that should never happen
686
+ scl = 1
687
+
688
+ ax = event.inaxes
689
+ ax._set_view_from_bbox([event.x, event.y, scl])
690
+
691
+ # If last scroll was done within the timing threshold, delete the
692
+ # previous view
693
+ if (time.time()-self.lastscroll) < self.scrollthresh:
694
+ self.toolmanager.get_tool(_views_positions).back()
695
+
696
+ self.figure.canvas.draw_idle() # force re-draw
697
+
698
+ self.lastscroll = time.time()
699
+ self.toolmanager.get_tool(_views_positions).push_current()
700
+
701
+
702
+ class ToolZoom(ZoomPanBase):
703
+ """A Tool for zooming using a rectangle selector."""
704
+
705
+ description = 'Zoom to rectangle'
706
+ image = 'mpl-data/images/zoom_to_rect'
707
+ default_keymap = property(lambda self: mpl.rcParams['keymap.zoom'])
708
+ cursor = cursors.SELECT_REGION
709
+ radio_group = 'default'
710
+
711
+ def __init__(self, *args):
712
+ super().__init__(*args)
713
+ self._ids_zoom = []
714
+
715
+ def _cancel_action(self):
716
+ for zoom_id in self._ids_zoom:
717
+ self.figure.canvas.mpl_disconnect(zoom_id)
718
+ self.toolmanager.trigger_tool('rubberband', self)
719
+ self.figure.canvas.draw_idle()
720
+ self._xypress = None
721
+ self._button_pressed = None
722
+ self._ids_zoom = []
723
+ return
724
+
725
+ def _press(self, event):
726
+ """Callback for mouse button presses in zoom-to-rectangle mode."""
727
+
728
+ # If we're already in the middle of a zoom, pressing another
729
+ # button works to "cancel"
730
+ if self._ids_zoom:
731
+ self._cancel_action()
732
+
733
+ if event.button == 1:
734
+ self._button_pressed = 1
735
+ elif event.button == 3:
736
+ self._button_pressed = 3
737
+ else:
738
+ self._cancel_action()
739
+ return
740
+
741
+ x, y = event.x, event.y
742
+
743
+ self._xypress = []
744
+ for i, a in enumerate(self.figure.get_axes()):
745
+ if (x is not None and y is not None and a.in_axes(event) and
746
+ a.get_navigate() and a.can_zoom()):
747
+ self._xypress.append((x, y, a, i, a._get_view()))
748
+
749
+ id1 = self.figure.canvas.mpl_connect(
750
+ 'motion_notify_event', self._mouse_move)
751
+ id2 = self.figure.canvas.mpl_connect(
752
+ 'key_press_event', self._switch_on_zoom_mode)
753
+ id3 = self.figure.canvas.mpl_connect(
754
+ 'key_release_event', self._switch_off_zoom_mode)
755
+
756
+ self._ids_zoom = id1, id2, id3
757
+ self._zoom_mode = event.key
758
+
759
+ def _switch_on_zoom_mode(self, event):
760
+ self._zoom_mode = event.key
761
+ self._mouse_move(event)
762
+
763
+ def _switch_off_zoom_mode(self, event):
764
+ self._zoom_mode = None
765
+ self._mouse_move(event)
766
+
767
+ def _mouse_move(self, event):
768
+ """Callback for mouse moves in zoom-to-rectangle mode."""
769
+
770
+ if self._xypress:
771
+ x, y = event.x, event.y
772
+ lastx, lasty, a, ind, view = self._xypress[0]
773
+ (x1, y1), (x2, y2) = np.clip(
774
+ [[lastx, lasty], [x, y]], a.bbox.min, a.bbox.max)
775
+ if self._zoom_mode == "x":
776
+ y1, y2 = a.bbox.intervaly
777
+ elif self._zoom_mode == "y":
778
+ x1, x2 = a.bbox.intervalx
779
+ self.toolmanager.trigger_tool(
780
+ 'rubberband', self, data=(x1, y1, x2, y2))
781
+
782
+ def _release(self, event):
783
+ """Callback for mouse button releases in zoom-to-rectangle mode."""
784
+
785
+ for zoom_id in self._ids_zoom:
786
+ self.figure.canvas.mpl_disconnect(zoom_id)
787
+ self._ids_zoom = []
788
+
789
+ if not self._xypress:
790
+ self._cancel_action()
791
+ return
792
+
793
+ done_ax = []
794
+
795
+ for cur_xypress in self._xypress:
796
+ x, y = event.x, event.y
797
+ lastx, lasty, a, _ind, view = cur_xypress
798
+ # ignore singular clicks - 5 pixels is a threshold
799
+ if abs(x - lastx) < 5 or abs(y - lasty) < 5:
800
+ self._cancel_action()
801
+ return
802
+
803
+ # detect twinx, twiny Axes and avoid double zooming
804
+ twinx = any(a.get_shared_x_axes().joined(a, a1) for a1 in done_ax)
805
+ twiny = any(a.get_shared_y_axes().joined(a, a1) for a1 in done_ax)
806
+ done_ax.append(a)
807
+
808
+ if self._button_pressed == 1:
809
+ direction = 'in'
810
+ elif self._button_pressed == 3:
811
+ direction = 'out'
812
+ else:
813
+ continue
814
+
815
+ a._set_view_from_bbox((lastx, lasty, x, y), direction,
816
+ self._zoom_mode, twinx, twiny)
817
+
818
+ self._zoom_mode = None
819
+ self.toolmanager.get_tool(_views_positions).push_current()
820
+ self._cancel_action()
821
+
822
+
823
+ class ToolPan(ZoomPanBase):
824
+ """Pan Axes with left mouse, zoom with right."""
825
+
826
+ default_keymap = property(lambda self: mpl.rcParams['keymap.pan'])
827
+ description = 'Pan axes with left mouse, zoom with right'
828
+ image = 'mpl-data/images/move'
829
+ cursor = cursors.MOVE
830
+ radio_group = 'default'
831
+
832
+ def __init__(self, *args):
833
+ super().__init__(*args)
834
+ self._id_drag = None
835
+
836
+ def _cancel_action(self):
837
+ self._button_pressed = None
838
+ self._xypress = []
839
+ self.figure.canvas.mpl_disconnect(self._id_drag)
840
+ self.toolmanager.messagelock.release(self)
841
+ self.figure.canvas.draw_idle()
842
+
843
+ def _press(self, event):
844
+ if event.button == 1:
845
+ self._button_pressed = 1
846
+ elif event.button == 3:
847
+ self._button_pressed = 3
848
+ else:
849
+ self._cancel_action()
850
+ return
851
+
852
+ x, y = event.x, event.y
853
+
854
+ self._xypress = []
855
+ for i, a in enumerate(self.figure.get_axes()):
856
+ if (x is not None and y is not None and a.in_axes(event) and
857
+ a.get_navigate() and a.can_pan()):
858
+ a.start_pan(x, y, event.button)
859
+ self._xypress.append((a, i))
860
+ self.toolmanager.messagelock(self)
861
+ self._id_drag = self.figure.canvas.mpl_connect(
862
+ 'motion_notify_event', self._mouse_move)
863
+
864
+ def _release(self, event):
865
+ if self._button_pressed is None:
866
+ self._cancel_action()
867
+ return
868
+
869
+ self.figure.canvas.mpl_disconnect(self._id_drag)
870
+ self.toolmanager.messagelock.release(self)
871
+
872
+ for a, _ind in self._xypress:
873
+ a.end_pan()
874
+ if not self._xypress:
875
+ self._cancel_action()
876
+ return
877
+
878
+ self.toolmanager.get_tool(_views_positions).push_current()
879
+ self._cancel_action()
880
+
881
+ def _mouse_move(self, event):
882
+ for a, _ind in self._xypress:
883
+ # safer to use the recorded button at the _press than current
884
+ # button: # multiple button can get pressed during motion...
885
+ a.drag_pan(self._button_pressed, event.key, event.x, event.y)
886
+ self.toolmanager.canvas.draw_idle()
887
+
888
+
889
+ class ToolHelpBase(ToolBase):
890
+ description = 'Print tool list, shortcuts and description'
891
+ default_keymap = property(lambda self: mpl.rcParams['keymap.help'])
892
+ image = 'mpl-data/images/help'
893
+
894
+ @staticmethod
895
+ def format_shortcut(key_sequence):
896
+ """
897
+ Convert a shortcut string from the notation used in rc config to the
898
+ standard notation for displaying shortcuts, e.g. 'ctrl+a' -> 'Ctrl+A'.
899
+ """
900
+ return (key_sequence if len(key_sequence) == 1 else
901
+ re.sub(r"\+[A-Z]", r"+Shift\g<0>", key_sequence).title())
902
+
903
+ def _format_tool_keymap(self, name):
904
+ keymaps = self.toolmanager.get_tool_keymap(name)
905
+ return ", ".join(self.format_shortcut(keymap) for keymap in keymaps)
906
+
907
+ def _get_help_entries(self):
908
+ return [(name, self._format_tool_keymap(name), tool.description)
909
+ for name, tool in sorted(self.toolmanager.tools.items())
910
+ if tool.description]
911
+
912
+ def _get_help_text(self):
913
+ entries = self._get_help_entries()
914
+ entries = ["{}: {}\n\t{}".format(*entry) for entry in entries]
915
+ return "\n".join(entries)
916
+
917
+ def _get_help_html(self):
918
+ fmt = "<tr><td>{}</td><td>{}</td><td>{}</td></tr>"
919
+ rows = [fmt.format(
920
+ "<b>Action</b>", "<b>Shortcuts</b>", "<b>Description</b>")]
921
+ rows += [fmt.format(*row) for row in self._get_help_entries()]
922
+ return ("<style>td {padding: 0px 4px}</style>"
923
+ "<table><thead>" + rows[0] + "</thead>"
924
+ "<tbody>".join(rows[1:]) + "</tbody></table>")
925
+
926
+
927
+ class ToolCopyToClipboardBase(ToolBase):
928
+ """Tool to copy the figure to the clipboard."""
929
+
930
+ description = 'Copy the canvas figure to clipboard'
931
+ default_keymap = property(lambda self: mpl.rcParams['keymap.copy'])
932
+
933
+ def trigger(self, *args, **kwargs):
934
+ message = "Copy tool is not available"
935
+ self.toolmanager.message_event(message, self)
936
+
937
+
938
+ #: The default tools to add to a tool manager.
939
+ default_tools = {'home': ToolHome, 'back': ToolBack, 'forward': ToolForward,
940
+ 'zoom': ToolZoom, 'pan': ToolPan,
941
+ 'subplots': ConfigureSubplotsBase,
942
+ 'save': SaveFigureBase,
943
+ 'grid': ToolGrid,
944
+ 'grid_minor': ToolMinorGrid,
945
+ 'fullscreen': ToolFullScreen,
946
+ 'quit': ToolQuit,
947
+ 'quit_all': ToolQuitAll,
948
+ 'xscale': ToolXScale,
949
+ 'yscale': ToolYScale,
950
+ 'position': ToolCursorPosition,
951
+ _views_positions: ToolViewsPositions,
952
+ 'cursor': ToolSetCursor,
953
+ 'rubberband': RubberbandBase,
954
+ 'help': ToolHelpBase,
955
+ 'copy': ToolCopyToClipboardBase,
956
+ }
957
+
958
+ #: The default tools to add to a container.
959
+ default_toolbar_tools = [['navigation', ['home', 'back', 'forward']],
960
+ ['zoompan', ['pan', 'zoom', 'subplots']],
961
+ ['io', ['save', 'help']]]
962
+
963
+
964
+ def add_tools_to_manager(toolmanager, tools=None):
965
+ """
966
+ Add multiple tools to a `.ToolManager`.
967
+
968
+ Parameters
969
+ ----------
970
+ toolmanager : `.backend_managers.ToolManager`
971
+ Manager to which the tools are added.
972
+ tools : {str: class_like}, optional
973
+ The tools to add in a {name: tool} dict, see
974
+ `.backend_managers.ToolManager.add_tool` for more info. If not specified, then
975
+ defaults to `.default_tools`.
976
+ """
977
+ if tools is None:
978
+ tools = default_tools
979
+ for name, tool in tools.items():
980
+ toolmanager.add_tool(name, tool)
981
+
982
+
983
+ def add_tools_to_container(container, tools=None):
984
+ """
985
+ Add multiple tools to the container.
986
+
987
+ Parameters
988
+ ----------
989
+ container : Container
990
+ `.backend_bases.ToolContainerBase` object that will get the tools
991
+ added.
992
+ tools : list, optional
993
+ List in the form ``[[group1, [tool1, tool2 ...]], [group2, [...]]]``
994
+ where the tools ``[tool1, tool2, ...]`` will display in group1.
995
+ See `.backend_bases.ToolContainerBase.add_tool` for details. If not specified,
996
+ then defaults to `.default_toolbar_tools`.
997
+ """
998
+ if tools is None:
999
+ tools = default_toolbar_tools
1000
+ for group, grouptools in tools:
1001
+ for position, tool in enumerate(grouptools):
1002
+ container.add_tool(tool, group, position)