matplotlib-rs 0.0.8__cp313-cp313-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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.cp313-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,808 @@
1
+ # Vendored from matplotlib 3.11 (see licenses/LICENSE_MATPLOTLIB), adapted for matplotlib_rs.
2
+ r"""
3
+ :mod:`~matplotlib.gridspec` contains classes that help to layout multiple
4
+ `~.axes.Axes` in a grid-like pattern within a figure.
5
+
6
+ The `GridSpec` specifies the overall grid structure. Individual cells within
7
+ the grid are referenced by `SubplotSpec`\s.
8
+
9
+ Often, users need not access this module directly, and can use higher-level
10
+ methods like `~.pyplot.subplots`, `~.pyplot.subplot_mosaic` and
11
+ `~.Figure.subfigures`. See the tutorial :ref:`arranging_axes` for a guide.
12
+ """
13
+
14
+ import copy
15
+ import logging
16
+ from numbers import Integral
17
+
18
+ import numpy as np
19
+
20
+ import matplotlib_rs as mpl
21
+ from matplotlib_rs import _api, _pylab_helpers, _tight_layout
22
+ from matplotlib_rs._api import UNSET as _UNSET
23
+ from matplotlib_rs.transforms import Bbox
24
+
25
+ _log = logging.getLogger(__name__)
26
+
27
+
28
+ class GridSpecBase:
29
+ """
30
+ A base class of GridSpec that specifies the geometry of the grid
31
+ that a subplot will be placed.
32
+ """
33
+
34
+ def __init__(self, nrows, ncols, height_ratios=None, width_ratios=None):
35
+ """
36
+ Parameters
37
+ ----------
38
+ nrows, ncols : int
39
+ The number of rows and columns of the grid.
40
+ width_ratios : array-like of length *ncols*, optional
41
+ Defines the relative widths of the columns. Each column gets a
42
+ relative width of ``width_ratios[i] / sum(width_ratios)``.
43
+ If not given, all columns will have the same width.
44
+ height_ratios : array-like of length *nrows*, optional
45
+ Defines the relative heights of the rows. Each row gets a
46
+ relative height of ``height_ratios[i] / sum(height_ratios)``.
47
+ If not given, all rows will have the same height.
48
+ """
49
+ if not isinstance(nrows, Integral) or nrows <= 0:
50
+ raise ValueError(
51
+ f"Number of rows must be a positive integer, not {nrows!r}")
52
+ if not isinstance(ncols, Integral) or ncols <= 0:
53
+ raise ValueError(
54
+ f"Number of columns must be a positive integer, not {ncols!r}")
55
+ self._nrows, self._ncols = nrows, ncols
56
+ self.set_height_ratios(height_ratios)
57
+ self.set_width_ratios(width_ratios)
58
+
59
+ def __repr__(self):
60
+ height_arg = (f', height_ratios={self._row_height_ratios!r}'
61
+ if len(set(self._row_height_ratios)) != 1 else '')
62
+ width_arg = (f', width_ratios={self._col_width_ratios!r}'
63
+ if len(set(self._col_width_ratios)) != 1 else '')
64
+ return '{clsname}({nrows}, {ncols}{optionals})'.format(
65
+ clsname=self.__class__.__name__,
66
+ nrows=self._nrows,
67
+ ncols=self._ncols,
68
+ optionals=height_arg + width_arg,
69
+ )
70
+
71
+ nrows = property(lambda self: self._nrows,
72
+ doc="The number of rows in the grid.")
73
+ ncols = property(lambda self: self._ncols,
74
+ doc="The number of columns in the grid.")
75
+
76
+ def get_geometry(self):
77
+ """
78
+ Return a tuple containing the number of rows and columns in the grid.
79
+ """
80
+ return self._nrows, self._ncols
81
+
82
+ def get_subplot_params(self, figure=None):
83
+ # Must be implemented in subclasses
84
+ pass
85
+
86
+ def new_subplotspec(self, loc, rowspan=1, colspan=1):
87
+ """
88
+ Create and return a `.SubplotSpec` instance.
89
+
90
+ Parameters
91
+ ----------
92
+ loc : (int, int)
93
+ The position of the subplot in the grid as
94
+ ``(row_index, column_index)``.
95
+ rowspan, colspan : int, default: 1
96
+ The number of rows and columns the subplot should span in the grid.
97
+ """
98
+ loc1, loc2 = loc
99
+ subplotspec = self[loc1:loc1+rowspan, loc2:loc2+colspan]
100
+ return subplotspec
101
+
102
+ def set_width_ratios(self, width_ratios):
103
+ """
104
+ Set the relative widths of the columns.
105
+
106
+ *width_ratios* must be of length *ncols*. Each column gets a relative
107
+ width of ``width_ratios[i] / sum(width_ratios)``.
108
+ """
109
+ if width_ratios is None:
110
+ width_ratios = [1] * self._ncols
111
+ elif len(width_ratios) != self._ncols:
112
+ raise ValueError('Expected the given number of width ratios to '
113
+ 'match the number of columns of the grid')
114
+ self._col_width_ratios = width_ratios
115
+
116
+ def get_width_ratios(self):
117
+ """
118
+ Return the width ratios.
119
+
120
+ This is *None* if no width ratios have been set explicitly.
121
+ """
122
+ return self._col_width_ratios
123
+
124
+ def set_height_ratios(self, height_ratios):
125
+ """
126
+ Set the relative heights of the rows.
127
+
128
+ *height_ratios* must be of length *nrows*. Each row gets a relative
129
+ height of ``height_ratios[i] / sum(height_ratios)``.
130
+ """
131
+ if height_ratios is None:
132
+ height_ratios = [1] * self._nrows
133
+ elif len(height_ratios) != self._nrows:
134
+ raise ValueError('Expected the given number of height ratios to '
135
+ 'match the number of rows of the grid')
136
+ self._row_height_ratios = height_ratios
137
+
138
+ def get_height_ratios(self):
139
+ """
140
+ Return the height ratios.
141
+
142
+ This is *None* if no height ratios have been set explicitly.
143
+ """
144
+ return self._row_height_ratios
145
+
146
+ def get_grid_positions(self, fig):
147
+ """
148
+ Return the positions of the grid cells in figure coordinates.
149
+
150
+ Parameters
151
+ ----------
152
+ fig : `~matplotlib.figure.Figure`
153
+ The figure the grid should be applied to. The subplot parameters
154
+ (margins and spacing between subplots) are taken from *fig*.
155
+
156
+ Returns
157
+ -------
158
+ bottoms, tops, lefts, rights : array
159
+ The bottom, top, left, right positions of the grid cells in
160
+ figure coordinates.
161
+ """
162
+ nrows, ncols = self.get_geometry()
163
+ subplot_params = self.get_subplot_params(fig)
164
+ left = subplot_params.left
165
+ right = subplot_params.right
166
+ bottom = subplot_params.bottom
167
+ top = subplot_params.top
168
+ wspace = subplot_params.wspace
169
+ hspace = subplot_params.hspace
170
+ tot_width = right - left
171
+ tot_height = top - bottom
172
+
173
+ # calculate accumulated heights of columns
174
+ cell_h = tot_height / (nrows + hspace*(nrows-1))
175
+ sep_h = hspace * cell_h
176
+ norm = cell_h * nrows / sum(self._row_height_ratios)
177
+ cell_heights = [r * norm for r in self._row_height_ratios]
178
+ sep_heights = [0] + ([sep_h] * (nrows-1))
179
+ cell_hs = np.cumsum(np.column_stack([sep_heights, cell_heights]).flat)
180
+
181
+ # calculate accumulated widths of rows
182
+ cell_w = tot_width / (ncols + wspace*(ncols-1))
183
+ sep_w = wspace * cell_w
184
+ norm = cell_w * ncols / sum(self._col_width_ratios)
185
+ cell_widths = [r * norm for r in self._col_width_ratios]
186
+ sep_widths = [0] + ([sep_w] * (ncols-1))
187
+ cell_ws = np.cumsum(np.column_stack([sep_widths, cell_widths]).flat)
188
+
189
+ fig_tops, fig_bottoms = (top - cell_hs).reshape((-1, 2)).T
190
+ fig_lefts, fig_rights = (left + cell_ws).reshape((-1, 2)).T
191
+ return fig_bottoms, fig_tops, fig_lefts, fig_rights
192
+
193
+ @staticmethod
194
+ def _check_gridspec_exists(figure, nrows, ncols):
195
+ """
196
+ Check if the figure already has a gridspec with these dimensions,
197
+ or create a new one
198
+ """
199
+ for ax in figure.get_axes():
200
+ gs = ax.get_gridspec()
201
+ if gs is not None:
202
+ if hasattr(gs, 'get_topmost_subplotspec'):
203
+ # This is needed for colorbar gridspec layouts.
204
+ # This is probably OK because this whole logic tree
205
+ # is for when the user is doing simple things with the
206
+ # add_subplot command. For complicated layouts
207
+ # like subgridspecs the proper gridspec is passed in...
208
+ gs = gs.get_topmost_subplotspec().get_gridspec()
209
+ if gs.get_geometry() == (nrows, ncols):
210
+ return gs
211
+ # else gridspec not found:
212
+ return GridSpec(nrows, ncols, figure=figure)
213
+
214
+ def __getitem__(self, key):
215
+ """Create and return a `.SubplotSpec` instance."""
216
+ nrows, ncols = self.get_geometry()
217
+
218
+ def _normalize(key, size, axis): # Includes last index.
219
+ orig_key = key
220
+ if isinstance(key, slice):
221
+ start, stop, _ = key.indices(size)
222
+ if stop > start:
223
+ return start, stop - 1
224
+ raise IndexError("GridSpec slice would result in no space "
225
+ "allocated for subplot")
226
+ else:
227
+ if key < 0:
228
+ key = key + size
229
+ if 0 <= key < size:
230
+ return key, key
231
+ elif axis is not None:
232
+ raise IndexError(f"index {orig_key} is out of bounds for "
233
+ f"axis {axis} with size {size}")
234
+ else: # flat index
235
+ raise IndexError(f"index {orig_key} is out of bounds for "
236
+ f"GridSpec with size {size}")
237
+
238
+ if isinstance(key, tuple):
239
+ try:
240
+ k1, k2 = key
241
+ except ValueError as err:
242
+ raise ValueError("Unrecognized subplot spec") from err
243
+ num1, num2 = np.ravel_multi_index(
244
+ [_normalize(k1, nrows, 0), _normalize(k2, ncols, 1)],
245
+ (nrows, ncols))
246
+ else: # Single key
247
+ num1, num2 = _normalize(key, nrows * ncols, None)
248
+
249
+ return SubplotSpec(self, num1, num2)
250
+
251
+ def subplots(self, *, sharex=False, sharey=False, squeeze=True,
252
+ subplot_kw=None):
253
+ """
254
+ Add all subplots specified by this `GridSpec` to its parent figure.
255
+
256
+ See `.Figure.subplots` for detailed documentation.
257
+ """
258
+
259
+ figure = self.figure
260
+
261
+ if figure is None:
262
+ raise ValueError("GridSpec.subplots() only works for GridSpecs "
263
+ "created with a parent figure")
264
+
265
+ if not isinstance(sharex, str):
266
+ sharex = "all" if sharex else "none"
267
+ if not isinstance(sharey, str):
268
+ sharey = "all" if sharey else "none"
269
+
270
+ _api.check_in_list(["all", "row", "col", "none", False, True],
271
+ sharex=sharex, sharey=sharey)
272
+ if subplot_kw is None:
273
+ subplot_kw = {}
274
+ # don't mutate kwargs passed by user...
275
+ subplot_kw = subplot_kw.copy()
276
+
277
+ # Create array to hold all Axes.
278
+ axarr = np.empty((self._nrows, self._ncols), dtype=object)
279
+ for row in range(self._nrows):
280
+ for col in range(self._ncols):
281
+ shared_with = {"none": None, "all": axarr[0, 0],
282
+ "row": axarr[row, 0], "col": axarr[0, col]}
283
+ subplot_kw["sharex"] = shared_with[sharex]
284
+ subplot_kw["sharey"] = shared_with[sharey]
285
+ axarr[row, col] = figure.add_subplot(
286
+ self[row, col], **subplot_kw)
287
+
288
+ # turn off redundant tick labeling
289
+ if sharex in ["col", "all"]:
290
+ for ax in axarr.flat:
291
+ ax._label_outer_xaxis(skip_non_rectangular_axes=True)
292
+ if sharey in ["row", "all"]:
293
+ for ax in axarr.flat:
294
+ ax._label_outer_yaxis(skip_non_rectangular_axes=True)
295
+
296
+ if squeeze:
297
+ # Discarding unneeded dimensions that equal 1. If we only have one
298
+ # subplot, just return it instead of a 1-element array.
299
+ return axarr.item() if axarr.size == 1 else axarr.squeeze()
300
+ else:
301
+ # Returned axis array will be always 2-d, even if nrows=ncols=1.
302
+ return axarr
303
+
304
+
305
+ class GridSpec(GridSpecBase):
306
+ """
307
+ A grid layout to place subplots within a figure.
308
+
309
+ The location of the grid cells is determined in a similar way to
310
+ `.SubplotParams` using *left*, *right*, *top*, *bottom*, *wspace*
311
+ and *hspace*.
312
+
313
+ Indexing a GridSpec instance returns a `.SubplotSpec`.
314
+ """
315
+ def __init__(self, nrows, ncols, figure=None,
316
+ left=None, bottom=None, right=None, top=None,
317
+ wspace=None, hspace=None,
318
+ width_ratios=None, height_ratios=None):
319
+ """
320
+ Parameters
321
+ ----------
322
+ nrows, ncols : int
323
+ The number of rows and columns of the grid.
324
+
325
+ figure : `.Figure`, optional
326
+ Only used for constrained layout to create a proper layoutgrid.
327
+
328
+ left, right, top, bottom : float, optional
329
+ Extent of the subplots as a fraction of figure width or height.
330
+ Left cannot be larger than right, and bottom cannot be larger than
331
+ top. If not given, the values will be inferred from a figure or
332
+ rcParams at draw time. See also `GridSpec.get_subplot_params`.
333
+
334
+ wspace : float, optional
335
+ The amount of width reserved for space between subplots,
336
+ expressed as a fraction of the average axis width.
337
+ If not given, the values will be inferred from a figure or
338
+ rcParams when necessary. See also `GridSpec.get_subplot_params`.
339
+
340
+ hspace : float, optional
341
+ The amount of height reserved for space between subplots,
342
+ expressed as a fraction of the average axis height.
343
+ If not given, the values will be inferred from a figure or
344
+ rcParams when necessary. See also `GridSpec.get_subplot_params`.
345
+
346
+ width_ratios : array-like of length *ncols*, optional
347
+ Defines the relative widths of the columns. Each column gets a
348
+ relative width of ``width_ratios[i] / sum(width_ratios)``.
349
+ If not given, all columns will have the same width.
350
+
351
+ height_ratios : array-like of length *nrows*, optional
352
+ Defines the relative heights of the rows. Each row gets a
353
+ relative height of ``height_ratios[i] / sum(height_ratios)``.
354
+ If not given, all rows will have the same height.
355
+
356
+ """
357
+ self.left = left
358
+ self.bottom = bottom
359
+ self.right = right
360
+ self.top = top
361
+ self.wspace = wspace
362
+ self.hspace = hspace
363
+ self.figure = figure
364
+
365
+ super().__init__(nrows, ncols,
366
+ width_ratios=width_ratios,
367
+ height_ratios=height_ratios)
368
+
369
+ _AllowedKeys = ["left", "bottom", "right", "top", "wspace", "hspace"]
370
+
371
+ def update(self, *, left=_UNSET, bottom=_UNSET, right=_UNSET, top=_UNSET,
372
+ wspace=_UNSET, hspace=_UNSET):
373
+ """
374
+ Update the subplot parameters of the grid.
375
+
376
+ Parameters that are not explicitly given are not changed. Setting a
377
+ parameter to *None* resets it to :rc:`figure.subplot.*`.
378
+
379
+ Parameters
380
+ ----------
381
+ left, right, top, bottom : float or None, optional
382
+ Extent of the subplots as a fraction of figure width or height.
383
+ wspace, hspace : float or None, optional
384
+ Spacing between the subplots as a fraction of the average subplot
385
+ width / height.
386
+ """
387
+ if left is not _UNSET:
388
+ self.left = left
389
+ if bottom is not _UNSET:
390
+ self.bottom = bottom
391
+ if right is not _UNSET:
392
+ self.right = right
393
+ if top is not _UNSET:
394
+ self.top = top
395
+ if wspace is not _UNSET:
396
+ self.wspace = wspace
397
+ if hspace is not _UNSET:
398
+ self.hspace = hspace
399
+
400
+ for figmanager in _pylab_helpers.Gcf.figs.values():
401
+ for ax in figmanager.canvas.figure.axes:
402
+ if ax.get_subplotspec() is not None:
403
+ ss = ax.get_subplotspec().get_topmost_subplotspec()
404
+ if ss.get_gridspec() == self:
405
+ fig = ax.get_figure(root=False)
406
+ ax._set_position(ax.get_subplotspec().get_position(fig))
407
+
408
+ def get_subplot_params(self, figure=None):
409
+ """
410
+ Return the `.SubplotParams` for the GridSpec.
411
+
412
+ In order of precedence the values are taken from
413
+
414
+ - non-*None* attributes of the GridSpec
415
+ - the provided *figure*
416
+ - :rc:`figure.subplot.*`
417
+
418
+ Note that the ``figure`` attribute of the GridSpec is always ignored.
419
+ """
420
+ if figure is None:
421
+ kw = {k: mpl.rcParams["figure.subplot."+k]
422
+ for k in self._AllowedKeys}
423
+ subplotpars = SubplotParams(**kw)
424
+ else:
425
+ subplotpars = copy.copy(figure.subplotpars)
426
+
427
+ subplotpars.update(**{k: getattr(self, k) for k in self._AllowedKeys})
428
+
429
+ return subplotpars
430
+
431
+ def locally_modified_subplot_params(self):
432
+ """
433
+ Return a list of the names of the subplot parameters explicitly set
434
+ in the GridSpec.
435
+
436
+ This is a subset of the attributes of `.SubplotParams`.
437
+ """
438
+ return [k for k in self._AllowedKeys if getattr(self, k)]
439
+
440
+ def tight_layout(self, figure, renderer=None,
441
+ pad=1.08, h_pad=None, w_pad=None, rect=None):
442
+ """
443
+ Adjust subplot parameters to give specified padding.
444
+
445
+ Parameters
446
+ ----------
447
+ figure : `.Figure`
448
+ The figure.
449
+ renderer : `.RendererBase` subclass, optional
450
+ The renderer to be used.
451
+ pad : float
452
+ Padding between the figure edge and the edges of subplots, as a
453
+ fraction of the font-size.
454
+ h_pad, w_pad : float, optional
455
+ Padding (height/width) between edges of adjacent subplots.
456
+ Defaults to *pad*.
457
+ rect : tuple (left, bottom, right, top), default: None
458
+ (left, bottom, right, top) rectangle in normalized figure
459
+ coordinates that the whole subplots area (including labels) will
460
+ fit into. Default (None) is the whole figure.
461
+ """
462
+ if renderer is None:
463
+ renderer = figure._get_renderer()
464
+ kwargs = _tight_layout.get_tight_layout_figure(
465
+ figure, figure.axes,
466
+ _tight_layout.get_subplotspec_list(figure.axes, grid_spec=self),
467
+ renderer, pad=pad, h_pad=h_pad, w_pad=w_pad, rect=rect)
468
+ if kwargs:
469
+ self.update(**kwargs)
470
+
471
+
472
+ class GridSpecFromSubplotSpec(GridSpecBase):
473
+ """
474
+ GridSpec whose subplot layout parameters are inherited from the
475
+ location specified by a given SubplotSpec.
476
+ """
477
+ def __init__(self, nrows, ncols,
478
+ subplot_spec,
479
+ wspace=None, hspace=None,
480
+ height_ratios=None, width_ratios=None):
481
+ """
482
+ Parameters
483
+ ----------
484
+ nrows, ncols : int
485
+ Number of rows and number of columns of the grid.
486
+ subplot_spec : SubplotSpec
487
+ Spec from which the layout parameters are inherited.
488
+ wspace, hspace : float, optional
489
+ See `GridSpec` for more details. If not specified default values
490
+ (from the figure or rcParams) are used.
491
+ height_ratios : array-like of length *nrows*, optional
492
+ See `GridSpecBase` for details.
493
+ width_ratios : array-like of length *ncols*, optional
494
+ See `GridSpecBase` for details.
495
+ """
496
+ self._wspace = wspace
497
+ self._hspace = hspace
498
+ if isinstance(subplot_spec, SubplotSpec):
499
+ self._subplot_spec = subplot_spec
500
+ else:
501
+ raise TypeError(
502
+ "subplot_spec must be type SubplotSpec, "
503
+ "usually from GridSpec, or axes.get_subplotspec.")
504
+ self.figure = self._subplot_spec.get_gridspec().figure
505
+ super().__init__(nrows, ncols,
506
+ width_ratios=width_ratios,
507
+ height_ratios=height_ratios)
508
+
509
+ def get_subplot_params(self, figure=None):
510
+ """Return a dictionary of subplot layout parameters."""
511
+ hspace = (self._hspace if self._hspace is not None
512
+ else figure.subplotpars.hspace if figure is not None
513
+ else mpl.rcParams["figure.subplot.hspace"])
514
+ wspace = (self._wspace if self._wspace is not None
515
+ else figure.subplotpars.wspace if figure is not None
516
+ else mpl.rcParams["figure.subplot.wspace"])
517
+
518
+ figbox = self._subplot_spec.get_position(figure)
519
+ left, bottom, right, top = figbox.extents
520
+
521
+ return SubplotParams(left=left, right=right,
522
+ bottom=bottom, top=top,
523
+ wspace=wspace, hspace=hspace)
524
+
525
+ def get_topmost_subplotspec(self):
526
+ """
527
+ Return the topmost `.SubplotSpec` instance associated with the subplot.
528
+ """
529
+ return self._subplot_spec.get_topmost_subplotspec()
530
+
531
+
532
+ class SubplotSpec:
533
+ """
534
+ The location of a subplot in a `GridSpec`.
535
+
536
+ .. note::
537
+
538
+ Likely, you will never instantiate a `SubplotSpec` yourself. Instead,
539
+ you will typically obtain one from a `GridSpec` using item-access.
540
+
541
+ Parameters
542
+ ----------
543
+ gridspec : `~matplotlib.gridspec.GridSpec`
544
+ The GridSpec, which the subplot is referencing.
545
+ num1, num2 : int
546
+ The subplot will occupy the *num1*-th cell of the given
547
+ *gridspec*. If *num2* is provided, the subplot will span between
548
+ *num1*-th cell and *num2*-th cell **inclusive**.
549
+
550
+ The index starts from 0.
551
+ """
552
+ def __init__(self, gridspec, num1, num2=None):
553
+ self._gridspec = gridspec
554
+ self.num1 = num1
555
+ self.num2 = num2
556
+
557
+ def __repr__(self):
558
+ return (f"{self.get_gridspec()}["
559
+ f"{self.rowspan.start}:{self.rowspan.stop}, "
560
+ f"{self.colspan.start}:{self.colspan.stop}]")
561
+
562
+ @staticmethod
563
+ def _from_subplot_args(figure, args):
564
+ """
565
+ Construct a `.SubplotSpec` from a parent `.Figure` and either
566
+
567
+ - a `.SubplotSpec` -- returned as is;
568
+ - one or three numbers -- a MATLAB-style subplot specifier.
569
+ """
570
+ if len(args) == 1:
571
+ arg, = args
572
+ if isinstance(arg, SubplotSpec):
573
+ return arg
574
+ elif not isinstance(arg, Integral):
575
+ raise ValueError(
576
+ f"Single argument to subplot must be a three-digit "
577
+ f"integer, not {arg!r}")
578
+ try:
579
+ rows, cols, num = map(int, str(arg))
580
+ except ValueError:
581
+ raise ValueError(
582
+ f"Single argument to subplot must be a three-digit "
583
+ f"integer, not {arg!r}") from None
584
+ elif len(args) == 3:
585
+ rows, cols, num = args
586
+ else:
587
+ raise _api.nargs_error("subplot", takes="1 or 3", given=len(args))
588
+
589
+ gs = GridSpec._check_gridspec_exists(figure, rows, cols)
590
+ if gs is None:
591
+ gs = GridSpec(rows, cols, figure=figure)
592
+ if isinstance(num, tuple) and len(num) == 2:
593
+ if not all(isinstance(n, Integral) for n in num):
594
+ raise ValueError(
595
+ f"Subplot specifier tuple must contain integers, not {num}"
596
+ )
597
+ i, j = num
598
+ else:
599
+ if not isinstance(num, Integral) or num < 1 or num > rows*cols:
600
+ raise ValueError(
601
+ f"num must be an integer with 1 <= num <= {rows*cols}, "
602
+ f"not {num!r}"
603
+ )
604
+ i = j = num
605
+ return gs[i-1:j]
606
+
607
+ # num2 is a property only to handle the case where it is None and someone
608
+ # mutates num1.
609
+
610
+ @property
611
+ def num2(self):
612
+ return self.num1 if self._num2 is None else self._num2
613
+
614
+ @num2.setter
615
+ def num2(self, value):
616
+ self._num2 = value
617
+
618
+ def get_gridspec(self):
619
+ return self._gridspec
620
+
621
+ def get_geometry(self):
622
+ """
623
+ Return the subplot geometry as tuple ``(n_rows, n_cols, start, stop)``.
624
+
625
+ The indices *start* and *stop* define the range of the subplot within
626
+ the `GridSpec`. *stop* is inclusive (i.e. for a single cell
627
+ ``start == stop``).
628
+ """
629
+ rows, cols = self.get_gridspec().get_geometry()
630
+ return rows, cols, self.num1, self.num2
631
+
632
+ @property
633
+ def rowspan(self):
634
+ """The rows spanned by this subplot, as a `range` object."""
635
+ ncols = self.get_gridspec().ncols
636
+ return range(self.num1 // ncols, self.num2 // ncols + 1)
637
+
638
+ @property
639
+ def colspan(self):
640
+ """The columns spanned by this subplot, as a `range` object."""
641
+ ncols = self.get_gridspec().ncols
642
+ # We explicitly support num2 referring to a column on num1's *left*, so
643
+ # we must sort the column indices here so that the range makes sense.
644
+ c1, c2 = sorted([self.num1 % ncols, self.num2 % ncols])
645
+ return range(c1, c2 + 1)
646
+
647
+ def is_first_row(self):
648
+ return self.rowspan.start == 0
649
+
650
+ def is_last_row(self):
651
+ return self.rowspan.stop == self.get_gridspec().nrows
652
+
653
+ def is_first_col(self):
654
+ return self.colspan.start == 0
655
+
656
+ def is_last_col(self):
657
+ return self.colspan.stop == self.get_gridspec().ncols
658
+
659
+ def get_position(self, figure):
660
+ """
661
+ Update the subplot position from ``figure.subplotpars``.
662
+ """
663
+ gridspec = self.get_gridspec()
664
+ nrows, ncols = gridspec.get_geometry()
665
+ rows, cols = np.unravel_index([self.num1, self.num2], (nrows, ncols))
666
+ fig_bottoms, fig_tops, fig_lefts, fig_rights = \
667
+ gridspec.get_grid_positions(figure)
668
+
669
+ fig_bottom = fig_bottoms[rows].min()
670
+ fig_top = fig_tops[rows].max()
671
+ fig_left = fig_lefts[cols].min()
672
+ fig_right = fig_rights[cols].max()
673
+ return Bbox.from_extents(fig_left, fig_bottom, fig_right, fig_top)
674
+
675
+ def get_topmost_subplotspec(self):
676
+ """
677
+ Return the topmost `SubplotSpec` instance associated with the subplot.
678
+ """
679
+ gridspec = self.get_gridspec()
680
+ if hasattr(gridspec, "get_topmost_subplotspec"):
681
+ return gridspec.get_topmost_subplotspec()
682
+ else:
683
+ return self
684
+
685
+ def __eq__(self, other):
686
+ """
687
+ Two SubplotSpecs are considered equal if they refer to the same
688
+ position(s) in the same `GridSpec`.
689
+ """
690
+ # other may not even have the attributes we are checking.
691
+ return ((self._gridspec, self.num1, self.num2)
692
+ == (getattr(other, "_gridspec", object()),
693
+ getattr(other, "num1", object()),
694
+ getattr(other, "num2", object())))
695
+
696
+ def __hash__(self):
697
+ return hash((self._gridspec, self.num1, self.num2))
698
+
699
+ def subgridspec(self, nrows, ncols, **kwargs):
700
+ """
701
+ Create a GridSpec within this subplot.
702
+
703
+ The created `.GridSpecFromSubplotSpec` will have this `SubplotSpec` as
704
+ a parent.
705
+
706
+ Parameters
707
+ ----------
708
+ nrows : int
709
+ Number of rows in grid.
710
+
711
+ ncols : int
712
+ Number of columns in grid.
713
+
714
+ Returns
715
+ -------
716
+ `.GridSpecFromSubplotSpec`
717
+
718
+ Other Parameters
719
+ ----------------
720
+ **kwargs
721
+ All other parameters are passed to `.GridSpecFromSubplotSpec`.
722
+
723
+ See Also
724
+ --------
725
+ matplotlib.pyplot.subplots
726
+
727
+ Examples
728
+ --------
729
+ Adding three subplots in the space occupied by a single subplot::
730
+
731
+ fig = plt.figure()
732
+ gs0 = fig.add_gridspec(3, 1)
733
+ ax1 = fig.add_subplot(gs0[0])
734
+ ax2 = fig.add_subplot(gs0[1])
735
+ gssub = gs0[2].subgridspec(1, 3)
736
+ for i in range(3):
737
+ fig.add_subplot(gssub[0, i])
738
+ """
739
+ return GridSpecFromSubplotSpec(nrows, ncols, self, **kwargs)
740
+
741
+
742
+ class SubplotParams:
743
+ """
744
+ Parameters defining the positioning of a subplots grid in a figure.
745
+ """
746
+
747
+ def __init__(self, left=None, bottom=None, right=None, top=None,
748
+ wspace=None, hspace=None):
749
+ """
750
+ Defaults are given by :rc:`figure.subplot.[name]`.
751
+
752
+ Parameters
753
+ ----------
754
+ left : float, optional
755
+ The position of the left edge of the subplots,
756
+ as a fraction of the figure width.
757
+ right : float, optional
758
+ The position of the right edge of the subplots,
759
+ as a fraction of the figure width.
760
+ bottom : float, optional
761
+ The position of the bottom edge of the subplots,
762
+ as a fraction of the figure height.
763
+ top : float, optional
764
+ The position of the top edge of the subplots,
765
+ as a fraction of the figure height.
766
+ wspace : float, optional
767
+ The width of the padding between subplots,
768
+ as a fraction of the average Axes width.
769
+ hspace : float, optional
770
+ The height of the padding between subplots,
771
+ as a fraction of the average Axes height.
772
+ """
773
+ for key in ["left", "bottom", "right", "top", "wspace", "hspace"]:
774
+ setattr(self, key, mpl.rcParams[f"figure.subplot.{key}"])
775
+ self.update(left, bottom, right, top, wspace, hspace)
776
+
777
+ def update(self, left=None, bottom=None, right=None, top=None,
778
+ wspace=None, hspace=None):
779
+ """
780
+ Update the dimensions of the passed parameters. *None* means unchanged.
781
+ """
782
+ if ((left if left is not None else self.left)
783
+ >= (right if right is not None else self.right)):
784
+ raise ValueError('left cannot be >= right')
785
+ if ((bottom if bottom is not None else self.bottom)
786
+ >= (top if top is not None else self.top)):
787
+ raise ValueError('bottom cannot be >= top')
788
+ if left is not None:
789
+ self.left = left
790
+ if right is not None:
791
+ self.right = right
792
+ if bottom is not None:
793
+ self.bottom = bottom
794
+ if top is not None:
795
+ self.top = top
796
+ if wspace is not None:
797
+ self.wspace = wspace
798
+ if hspace is not None:
799
+ self.hspace = hspace
800
+
801
+ def reset(self):
802
+ """Restore the subplot positioning parameters to the default rcParams values"""
803
+ for key in self.to_dict():
804
+ setattr(self, key, mpl.rcParams[f'figure.subplot.{key}'])
805
+
806
+ def to_dict(self):
807
+ """Return a copy of the subplot parameters as a dict."""
808
+ return self.__dict__.copy()