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,552 @@
1
+ """
2
+ The Agg backend of matplotlib_rs.
3
+
4
+ `RendererAgg` keeps the API of matplotlib's Agg renderer; the drawing
5
+ primitives run in the Rust port of Agg. Figures are drawn by the Rust core;
6
+ Python artists that the core does not implement are drawn by their own
7
+ ``draw`` method through a `RendererAgg` that proxies the figure's renderer.
8
+
9
+ Parts of this file are from matplotlib 3.11 (see licenses/LICENSE_MATPLOTLIB).
10
+ """
11
+
12
+ from contextlib import contextmanager, nullcontext
13
+ import io
14
+ import math
15
+
16
+ import numpy as np
17
+
18
+ import matplotlib_rs as mpl
19
+ from matplotlib_rs import _api, cbook, _mplrs, _png
20
+ from matplotlib_rs.backend_bases import (
21
+ _Backend, FigureCanvasBase, FigureManagerBase, RendererBase)
22
+ from matplotlib_rs.font_manager import fontManager as _fontManager, get_font
23
+ from matplotlib_rs.ft2font import LoadFlags, RenderMode
24
+ from matplotlib_rs.path import Path
25
+ from matplotlib_rs.transforms import Bbox, BboxBase
26
+
27
+
28
+ def get_hinting_flag():
29
+ mapping = {
30
+ 'default': LoadFlags.DEFAULT,
31
+ 'no_autohint': LoadFlags.NO_AUTOHINT,
32
+ 'force_autohint': LoadFlags.FORCE_AUTOHINT,
33
+ 'no_hinting': LoadFlags.NO_HINTING,
34
+ True: LoadFlags.FORCE_AUTOHINT,
35
+ False: LoadFlags.NO_HINTING,
36
+ 'either': LoadFlags.DEFAULT,
37
+ 'native': LoadFlags.NO_AUTOHINT,
38
+ 'auto': LoadFlags.FORCE_AUTOHINT,
39
+ 'none': LoadFlags.NO_HINTING,
40
+ }
41
+ return mapping[mpl.rcParams['text.hinting']]
42
+
43
+
44
+ # ---------------------------------------------------------------------------
45
+ # argument conversion for the Rust renderer
46
+
47
+
48
+ def _matrix(transform):
49
+ if transform is None:
50
+ return np.eye(3)
51
+ if hasattr(transform, "get_matrix"):
52
+ return np.ascontiguousarray(transform.get_matrix(), dtype=float)
53
+ return np.ascontiguousarray(transform, dtype=float)
54
+
55
+
56
+ def _vertices(path):
57
+ return np.ascontiguousarray(path.vertices, dtype=float).reshape(-1, 2)
58
+
59
+
60
+ def _codes(path):
61
+ c = path.codes
62
+ return None if c is None else np.ascontiguousarray(c, dtype=np.uint8)
63
+
64
+
65
+ def _gc_dict(gc):
66
+ """The attributes of a GraphicsContext read by matplotlib's Agg."""
67
+ off, dashes = gc.get_dashes()
68
+ d = {
69
+ "linewidth": float(gc._linewidth),
70
+ "alpha": float(gc._alpha),
71
+ "forced_alpha": bool(gc._forced_alpha),
72
+ "rgb": tuple(map(float, gc._rgb)),
73
+ "antialiased": bool(gc._antialiased),
74
+ "capstyle": gc._capstyle.name,
75
+ "joinstyle": gc._joinstyle.name,
76
+ "dashes": (0.0 if off is None else float(off),
77
+ None if dashes is None else [float(v) for v in dashes]),
78
+ "snap": gc.get_snap(),
79
+ }
80
+ cr = gc._cliprect
81
+ if cr is not None:
82
+ (x0, y0), (x1, y1) = np.asarray(cr, dtype=float) if not isinstance(cr, BboxBase) \
83
+ else cr.get_points()
84
+ d["cliprect"] = (float(x0), float(y0), float(x1), float(y1))
85
+ tpath, tr = gc.get_clip_path()
86
+ if tpath is not None:
87
+ d["clippath"] = (_vertices(tpath), _codes(tpath), _matrix(tr))
88
+ hp = gc.get_hatch_path()
89
+ if hp is not None:
90
+ hc = gc.get_hatch_color()
91
+ d["hatch"] = (_vertices(hp), _codes(hp),
92
+ (0.0, 0.0, 0.0, 0.0) if hc is None else tuple(map(float, hc)),
93
+ float(gc.get_hatch_linewidth()))
94
+ sk = gc.get_sketch_params()
95
+ if sk is not None:
96
+ d["sketch"] = tuple(map(float, sk))
97
+ return d
98
+
99
+
100
+ def _face(rgbFace):
101
+ if rgbFace is None:
102
+ return None
103
+ return tuple(map(float, rgbFace))
104
+
105
+
106
+ def _fontprops(prop):
107
+ from matplotlib_rs.text import _rs_fontprops
108
+ return _rs_fontprops(prop)
109
+
110
+
111
+ class RendererAgg(RendererBase):
112
+ """
113
+ The renderer handles all the drawing primitives using a graphics
114
+ context instance that controls the colors/styles.
115
+ """
116
+
117
+ def __init__(self, width, height, dpi, *, _target=None):
118
+ super().__init__()
119
+ self.dpi = dpi
120
+ self.width = width
121
+ self.height = height
122
+ if _target is None:
123
+ _target = _mplrs.RendererAgg(int(width), int(height), dpi)
124
+ self._renderer = _target
125
+ self._filter_renderers = []
126
+ self._mathtext_parser = None
127
+ self.bbox = Bbox.from_bounds(0, 0, self.width, self.height)
128
+
129
+ @classmethod
130
+ def _for_target(cls, target):
131
+ """A renderer drawing on the renderer of a figure draw in progress."""
132
+ return cls(target.width, target.height, target.dpi, _target=target)
133
+
134
+ @property
135
+ def mathtext_parser(self):
136
+ if self._mathtext_parser is None:
137
+ from matplotlib_rs.mathtext import MathTextParser
138
+ self._mathtext_parser = MathTextParser('path')
139
+ return self._mathtext_parser
140
+
141
+ @property
142
+ def _rs_disabled(self):
143
+ return bool(self.__dict__.get("_rs_disabled_flag")) or self._renderer.disabled
144
+
145
+ @contextmanager
146
+ def _draw_disabled(self):
147
+ with super()._draw_disabled(), cbook._setattr_cm(self, _rs_disabled_flag=True):
148
+ yield
149
+
150
+ def __getstate__(self):
151
+ return {'width': self.width, 'height': self.height, 'dpi': self.dpi}
152
+
153
+ def __setstate__(self, state):
154
+ self.__init__(state['width'], state['height'], state['dpi'])
155
+
156
+ # -- primitives ----------------------------------------------------------
157
+ def draw_path(self, gc, path, transform, rgbFace=None):
158
+ # docstring inherited
159
+ nmax = mpl.rcParams['agg.path.chunksize'] # here at least for testing
160
+ npts = path.vertices.shape[0]
161
+
162
+ if (npts > nmax > 100 and path.should_simplify and
163
+ rgbFace is None and gc.get_hatch() is None):
164
+ nch = np.ceil(npts / nmax)
165
+ chsize = int(np.ceil(npts / nch))
166
+ i0 = np.arange(0, npts, chsize)
167
+ i1 = np.zeros_like(i0)
168
+ i1[:-1] = i0[1:] - 1
169
+ i1[-1] = npts
170
+ for ii0, ii1 in zip(i0, i1):
171
+ v = path.vertices[ii0:ii1, :]
172
+ c = path.codes
173
+ if c is not None:
174
+ c = c[ii0:ii1]
175
+ c[0] = Path.MOVETO # move to end of last chunk
176
+ p = Path(v, c)
177
+ p.simplify_threshold = path.simplify_threshold
178
+ self._draw_path(gc, p, transform, rgbFace)
179
+ else:
180
+ self._draw_path(gc, path, transform, rgbFace)
181
+
182
+ def _draw_path(self, gc, path, transform, rgbFace):
183
+ self._renderer.draw_path(
184
+ _gc_dict(gc), _vertices(path), _codes(path), bool(path.should_simplify),
185
+ float(path.simplify_threshold), _matrix(transform), _face(rgbFace))
186
+
187
+ def draw_markers(self, gc, marker_path, marker_trans, path, trans, rgbFace=None):
188
+ # docstring inherited
189
+ self._renderer.draw_markers(
190
+ _gc_dict(gc), _vertices(marker_path), _codes(marker_path), _matrix(marker_trans),
191
+ _vertices(path), _codes(path), _matrix(trans), _face(rgbFace))
192
+
193
+ def draw_path_collection(self, gc, master_transform, paths, all_transforms,
194
+ offsets, offset_trans, facecolors, edgecolors,
195
+ linewidths, linestyles, antialiaseds, urls,
196
+ offset_position, *, hatchcolors=None):
197
+ # docstring inherited
198
+ if isinstance(paths, (list, tuple)) and not paths:
199
+ # Nothing is drawn without paths (Collection.draw calls this way
200
+ # to find out whether the renderer takes hatchcolors).
201
+ return
202
+ if (isinstance(all_transforms, np.ndarray) and all_transforms.ndim == 3
203
+ and all_transforms.shape[1:] == (3, 3)
204
+ and all_transforms.dtype != object):
205
+ # (the matrices of a collection with sizes: no loop over them)
206
+ transforms = np.ascontiguousarray(all_transforms, dtype=float)
207
+ else:
208
+ transforms = np.asarray(
209
+ [_matrix(t) for t in all_transforms] if len(all_transforms) else
210
+ np.zeros((0, 3, 3)), dtype=float).reshape(-1, 3, 3)
211
+ offsets = np.ascontiguousarray(offsets, dtype=float).reshape(-1, 2) \
212
+ if len(offsets) else np.zeros((0, 2))
213
+ fc = np.ascontiguousarray(facecolors, dtype=float).reshape(-1, 4) \
214
+ if len(facecolors) else np.zeros((0, 4))
215
+ ec = np.ascontiguousarray(edgecolors, dtype=float).reshape(-1, 4) \
216
+ if len(edgecolors) else np.zeros((0, 4))
217
+ lw = np.ascontiguousarray(linewidths, dtype=float).ravel()
218
+ dashes = [(0.0 if o is None else float(o),
219
+ None if d is None else [float(v) for v in d])
220
+ for o, d in linestyles]
221
+ aa = np.ascontiguousarray(antialiaseds, dtype=np.uint8).ravel()
222
+ hc = np.ascontiguousarray(hatchcolors, dtype=float).reshape(-1, 4) \
223
+ if hatchcolors is not None and len(hatchcolors) else np.zeros((0, 4))
224
+ self._renderer.draw_path_collection(
225
+ _gc_dict(gc), _matrix(master_transform),
226
+ [(_vertices(p), _codes(p)) for p in paths],
227
+ transforms, offsets, _matrix(offset_trans), fc, ec, lw, dashes, aa, hc)
228
+
229
+ def draw_image(self, gc, x, y, im):
230
+ # docstring inherited
231
+ im = np.ascontiguousarray(im, dtype=np.uint8)
232
+ self._renderer.draw_image(_gc_dict(gc), float(x), float(y), im)
233
+
234
+ def draw_quad_mesh(self, gc, master_transform, meshWidth, meshHeight,
235
+ coordinates, offsets, offsetTrans, facecolors,
236
+ antialiased, edgecolors):
237
+ # docstring inherited
238
+ coordinates = np.ascontiguousarray(
239
+ np.asarray(coordinates, dtype=float).reshape(
240
+ meshHeight + 1, meshWidth + 1, 2))
241
+ offsets = np.ascontiguousarray(offsets, dtype=float).reshape(-1, 2) \
242
+ if len(offsets) else np.zeros((0, 2))
243
+ fc = np.ascontiguousarray(facecolors, dtype=float).reshape(-1, 4) \
244
+ if len(facecolors) else np.zeros((0, 4))
245
+ if edgecolors is None:
246
+ edgecolors = facecolors
247
+ ec = np.ascontiguousarray(edgecolors, dtype=float).reshape(-1, 4) \
248
+ if len(edgecolors) else np.zeros((0, 4))
249
+ self._renderer.draw_quad_mesh(
250
+ _gc_dict(gc), _matrix(master_transform), int(meshWidth),
251
+ int(meshHeight), coordinates, offsets, _matrix(offsetTrans), fc,
252
+ bool(antialiased), ec)
253
+
254
+ def draw_gouraud_triangles(self, gc, triangles_array, colors_array,
255
+ transform):
256
+ # docstring inherited
257
+ self._renderer.draw_gouraud_triangles(
258
+ _gc_dict(gc),
259
+ np.ascontiguousarray(triangles_array, dtype=float).reshape(-1, 3, 2),
260
+ np.ascontiguousarray(colors_array, dtype=float).reshape(-1, 3, 4),
261
+ _matrix(transform))
262
+
263
+ def _draw_text_glyphs_and_boxes(self, gc, x, y, angle, glyphs, boxes):
264
+ self._renderer.draw_glyphs_and_boxes(
265
+ _gc_dict(gc), float(x), float(y), float(angle),
266
+ [(font.fname, int(getattr(font, "face_index", 0)), float(size),
267
+ int(glyph_index), float(slant), float(extend), float(dx), float(dy))
268
+ for font, size, glyph_index, slant, extend, dx, dy in glyphs],
269
+ [tuple(map(float, b)) for b in boxes])
270
+
271
+ def draw_mathtext(self, gc, x, y, s, prop, angle):
272
+ """Draw mathtext using :mod:`matplotlib.mathtext`."""
273
+ parse = self.mathtext_parser.parse(
274
+ s, self.dpi, prop, antialiased=gc.get_antialiased())
275
+ self._draw_text_glyphs_and_boxes(
276
+ gc, x, y, angle,
277
+ ((font, size, glyph_index, 0, 1, dx, dy)
278
+ for font, size, _char, glyph_index, dx, dy in parse.glyphs),
279
+ parse.rects)
280
+
281
+ def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
282
+ # docstring inherited
283
+ if ismath == "TeX":
284
+ return self.draw_tex(gc, x, y, s, prop, angle, mtext=mtext)
285
+ if ismath:
286
+ return self.draw_mathtext(gc, x, y, s, prop, angle)
287
+ self._renderer.draw_text(_gc_dict(gc), float(x), float(y), s,
288
+ _fontprops(prop), float(angle), False)
289
+
290
+ def get_text_width_height_descent(self, s, prop, ismath):
291
+ # docstring inherited
292
+ _api.check_in_list(["TeX", True, False], ismath=ismath)
293
+ if ismath == "TeX":
294
+ return super().get_text_width_height_descent(s, prop, ismath)
295
+
296
+ if ismath:
297
+ parse = self.mathtext_parser.parse(s, self.dpi, prop)
298
+ return parse.width, parse.height, parse.depth
299
+
300
+ whd = self._renderer.get_text_width_height_descent(s, _fontprops(prop), False)
301
+ from .._foreign import warn_missing_glyphs
302
+ warn_missing_glyphs()
303
+ return whd
304
+
305
+ def draw_tex(self, gc, x, y, s, prop, angle, *, mtext=None):
306
+ raise NotImplementedError("matplotlib_rs does not support usetex yet")
307
+
308
+ def get_canvas_width_height(self):
309
+ # docstring inherited
310
+ return self.width, self.height
311
+
312
+ def _prepare_font(self, font_prop):
313
+ """
314
+ Get the `.FT2Font` for *font_prop*, clear its buffer, and set its size.
315
+ """
316
+ font = get_font(_fontManager._find_fonts_by_props(font_prop))
317
+ font.clear()
318
+ size = font_prop.get_size_in_points()
319
+ font.set_size(size, self.dpi)
320
+ return font
321
+
322
+ def points_to_pixels(self, points):
323
+ # docstring inherited
324
+ return points * self.dpi / 72
325
+
326
+ def buffer_rgba(self):
327
+ return memoryview(self._renderer.buffer_rgba())
328
+
329
+ def _encode_png(self, dpi, text, level, strategy):
330
+ """The PNG file of the buffer, encoded in place (see `._png.encode`)."""
331
+ return self._renderer.encode_png(
332
+ (float(dpi[0]), float(dpi[1])), text, level, strategy)
333
+
334
+ def tostring_argb(self):
335
+ return np.asarray(self._renderer.buffer_rgba()).take([3, 0, 1, 2], axis=2).tobytes()
336
+
337
+ def clear(self):
338
+ self._renderer.clear()
339
+
340
+ def option_image_nocomposite(self):
341
+ # docstring inherited
342
+
343
+ # It is generally faster to composite each image directly to
344
+ # the Figure, and there's no file size benefit to compositing
345
+ # with the Agg backend
346
+ return True
347
+
348
+ def option_scale_image(self):
349
+ # docstring inherited
350
+ return False
351
+
352
+ def copy_from_bbox(self, bbox):
353
+ r = np.asarray(bbox, dtype=float)
354
+ if r.shape == (2, 2):
355
+ (x1, y1), (x2, y2) = r
356
+ elif r.shape == (4,):
357
+ x1, y1, x2, y2 = r
358
+ else:
359
+ raise ValueError("Invalid bounding box")
360
+ return self._renderer.copy_from_bbox(
361
+ float(x1), float(y1), float(x2), float(y2))
362
+
363
+ def restore_region(self, region, bbox=None, xy=None):
364
+ """
365
+ Restore the saved region. If bbox (instance of BboxBase, or
366
+ its extents) is given, only the region specified by the bbox
367
+ will be restored. *xy* (a pair of floats) optionally
368
+ specifies the new position (the LLC of the original region,
369
+ not the LLC of the bbox) where the region will be restored.
370
+
371
+ >>> region = renderer.copy_from_bbox()
372
+ >>> x1, y1, x2, y2 = region.get_extents()
373
+ >>> renderer.restore_region(region, bbox=(x1+dx, y1, x2, y2),
374
+ ... xy=(x1-dx, y1))
375
+
376
+ """
377
+ if bbox is not None or xy is not None:
378
+ if bbox is None:
379
+ x1, y1, x2, y2 = region.get_extents()
380
+ elif isinstance(bbox, BboxBase):
381
+ x1, y1, x2, y2 = bbox.extents
382
+ else:
383
+ x1, y1, x2, y2 = bbox
384
+
385
+ if xy is None:
386
+ ox, oy = x1, y1
387
+ else:
388
+ ox, oy = xy
389
+
390
+ # The incoming data is float, but the _renderer type-checking wants
391
+ # to see integers.
392
+ self._renderer.restore_region(region, int(x1), int(y1),
393
+ int(x2), int(y2), int(ox), int(oy))
394
+
395
+ else:
396
+ self._renderer.restore_region(region)
397
+
398
+ def start_filter(self):
399
+ """
400
+ Start filtering. It simply creates a new canvas (the old one is saved).
401
+ """
402
+ self._filter_renderers.append(self._renderer)
403
+ self._renderer = _mplrs.RendererAgg(int(self.width), int(self.height), self.dpi)
404
+
405
+ def stop_filter(self, post_processing):
406
+ """
407
+ Save the current canvas as an image and apply post processing.
408
+ """
409
+ orig_img = np.asarray(self.buffer_rgba())
410
+ slice_y, slice_x = cbook._get_nonzero_slices(orig_img[..., 3])
411
+ cropped_img = orig_img[slice_y, slice_x]
412
+
413
+ self._renderer = self._filter_renderers.pop()
414
+
415
+ if cropped_img.size:
416
+ img, ox, oy = post_processing(cropped_img / 255, self.dpi)
417
+ gc = self.new_gc()
418
+ if img.dtype.kind == 'f':
419
+ img = np.asarray(img * 255., np.uint8)
420
+ self.draw_image(
421
+ gc, slice_x.start + ox, int(self.height) - slice_y.stop + oy,
422
+ img[::-1])
423
+
424
+
425
+ class FigureCanvasAgg(FigureCanvasBase):
426
+ # docstring inherited
427
+
428
+ _lastKey = None # Overwritten per-instance on the first draw.
429
+
430
+ def copy_from_bbox(self, bbox):
431
+ renderer = self.get_renderer()
432
+ return renderer.copy_from_bbox(bbox)
433
+
434
+ def restore_region(self, region, bbox=None, xy=None):
435
+ renderer = self.get_renderer()
436
+ return renderer.restore_region(region, bbox, xy)
437
+
438
+ def draw(self):
439
+ # docstring inherited
440
+ self.renderer = self.get_renderer()
441
+ self.renderer.clear()
442
+ with (self.toolbar._wait_cursor_for_draw_cm() if self.toolbar
443
+ else nullcontext()):
444
+ self.figure.draw(self.renderer)
445
+ # A GUI class may be need to update a window using this draw, so
446
+ # don't forget to call the superclass.
447
+ super().draw()
448
+
449
+ def get_renderer(self):
450
+ w, h = self.get_width_height(physical=True)
451
+ key = w, h, self.figure.dpi
452
+ reuse_renderer = (self._lastKey == key)
453
+ if not reuse_renderer:
454
+ self.renderer = RendererAgg(w, h, self.figure.dpi)
455
+ self._lastKey = key
456
+ return self.renderer
457
+
458
+ def tostring_argb(self):
459
+ return self.renderer.tostring_argb()
460
+
461
+ def buffer_rgba(self):
462
+ return self.renderer.buffer_rgba()
463
+
464
+ def print_raw(self, filename_or_obj, *, metadata=None):
465
+ if metadata is not None:
466
+ raise ValueError("metadata not supported for raw/rgba")
467
+ FigureCanvasAgg.draw(self)
468
+ renderer = self.get_renderer()
469
+ with cbook.open_file_cm(filename_or_obj, "wb") as fh:
470
+ fh.write(renderer.buffer_rgba())
471
+
472
+ print_rgba = print_raw
473
+
474
+ def _print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata=None):
475
+ FigureCanvasAgg.draw(self)
476
+ mpl.image.imsave(
477
+ filename_or_obj, self.buffer_rgba(), format=fmt, origin="upper",
478
+ dpi=self.figure.dpi, metadata=metadata, pil_kwargs=pil_kwargs)
479
+
480
+ def print_png(self, filename_or_obj, *, metadata=None, pil_kwargs=None):
481
+ """
482
+ Write the figure to a PNG file.
483
+
484
+ Parameters
485
+ ----------
486
+ filename_or_obj : str or path-like or file-like
487
+ The file to write to.
488
+
489
+ metadata : dict, optional
490
+ Metadata in the PNG file as key-value pairs of bytes or latin-1
491
+ encodable strings. According to the PNG specification, keys must
492
+ be shorter than 79 chars. The default ``"Software"`` key can be
493
+ removed by setting it to None.
494
+
495
+ pil_kwargs : dict, optional
496
+ Keyword arguments with the meaning of `PIL.Image.Image.save`'s;
497
+ see `matplotlib_rs._imageio` for the supported ones (``pnginfo``
498
+ may be a Pillow ``PngInfo``).
499
+
500
+ Notes
501
+ -----
502
+ The pixels are encoded by the Rust core in place, on several threads,
503
+ at zlib level 6 by default (as Pillow); Pillow is not used.
504
+ """
505
+ options = _png.native_options(pil_kwargs)
506
+ if options is None:
507
+ return self._print_pil(filename_or_obj, "png", pil_kwargs, metadata)
508
+ level, strategy, dpi = options
509
+ FigureCanvasAgg.draw(self)
510
+ text = _png.text_chunks({
511
+ "Software": f"Matplotlib version{mpl.__version__}, https://matplotlib.org/",
512
+ **(metadata or {})})
513
+ if dpi is None:
514
+ dpi = (self.figure.dpi, self.figure.dpi)
515
+ data = self.renderer._encode_png(dpi, text, level, strategy)
516
+ _png.write_bytes(filename_or_obj, data)
517
+
518
+ def print_to_buffer(self):
519
+ FigureCanvasAgg.draw(self)
520
+ renderer = self.get_renderer()
521
+ return (bytes(renderer.buffer_rgba()),
522
+ (int(renderer.width), int(renderer.height)))
523
+
524
+ def print_gif(self, filename_or_obj, *, metadata=None, pil_kwargs=None):
525
+ self._print_pil(filename_or_obj, "gif", pil_kwargs, metadata)
526
+
527
+ def print_jpg(self, filename_or_obj, *, metadata=None, pil_kwargs=None):
528
+ # savefig() has already applied savefig.facecolor; we now set it to
529
+ # white to make imsave() blend semi-transparent figures against an
530
+ # assumed white background.
531
+ with mpl.rc_context({"savefig.facecolor": "white"}):
532
+ self._print_pil(filename_or_obj, "jpeg", pil_kwargs, metadata)
533
+
534
+ print_jpeg = print_jpg
535
+
536
+ def print_tif(self, filename_or_obj, *, metadata=None, pil_kwargs=None):
537
+ self._print_pil(filename_or_obj, "tiff", pil_kwargs, metadata)
538
+
539
+ print_tiff = print_tif
540
+
541
+ def print_webp(self, filename_or_obj, *, metadata=None, pil_kwargs=None):
542
+ self._print_pil(filename_or_obj, "webp", pil_kwargs, metadata)
543
+
544
+ def print_avif(self, filename_or_obj, *, metadata=None, pil_kwargs=None):
545
+ self._print_pil(filename_or_obj, "avif", pil_kwargs, metadata)
546
+
547
+
548
+ @_Backend.export
549
+ class _BackendAgg(_Backend):
550
+ backend_version = 'v2.2'
551
+ FigureCanvas = FigureCanvasAgg
552
+ FigureManager = FigureManagerBase
@@ -0,0 +1,123 @@
1
+ # Vendored from matplotlib 3.11 (see licenses/LICENSE_MATPLOTLIB), adapted for matplotlib_rs.
2
+ import numpy as np
3
+
4
+ from matplotlib_rs import cbook
5
+ from .backend_agg import RendererAgg
6
+ from matplotlib_rs._tight_bbox import process_figure_for_rasterizing
7
+
8
+
9
+ class MixedModeRenderer:
10
+ """
11
+ A helper class to implement a renderer that switches between
12
+ vector and raster drawing. An example may be a PDF writer, where
13
+ most things are drawn with PDF vector commands, but some very
14
+ complex objects, such as quad meshes, are rasterised and then
15
+ output as images.
16
+ """
17
+ def __init__(self, figure, width, height, dpi, vector_renderer,
18
+ raster_renderer_class=None,
19
+ bbox_inches_restore=None):
20
+ """
21
+ Parameters
22
+ ----------
23
+ figure : `~matplotlib.figure.Figure`
24
+ The figure instance.
25
+ width : float
26
+ The width of the canvas in logical units
27
+ height : float
28
+ The height of the canvas in logical units
29
+ dpi : float
30
+ The dpi of the canvas
31
+ vector_renderer : `~matplotlib.backend_bases.RendererBase`
32
+ An instance of a subclass of
33
+ `~matplotlib.backend_bases.RendererBase` that will be used for the
34
+ vector drawing.
35
+ raster_renderer_class : `~matplotlib.backend_bases.RendererBase`
36
+ The renderer class to use for the raster drawing. If not provided,
37
+ this will use the Agg backend (which is currently the only viable
38
+ option anyway.)
39
+
40
+ """
41
+ if raster_renderer_class is None:
42
+ raster_renderer_class = RendererAgg
43
+
44
+ self._raster_renderer_class = raster_renderer_class
45
+ self._width = width
46
+ self._height = height
47
+ self.dpi = dpi
48
+
49
+ self._vector_renderer = vector_renderer
50
+
51
+ self._raster_renderer = None
52
+
53
+ # A reference to the figure is needed as we need to change
54
+ # the figure dpi before and after the rasterization. Although
55
+ # this looks ugly, I couldn't find a better solution. -JJL
56
+ self.figure = figure
57
+ self._figdpi = figure.dpi
58
+
59
+ self._bbox_inches_restore = bbox_inches_restore
60
+
61
+ self._renderer = vector_renderer
62
+
63
+ def __getattr__(self, attr):
64
+ # Proxy everything that hasn't been overridden to the base
65
+ # renderer. Things that *are* overridden can call methods
66
+ # on self._renderer directly, but must not cache/store
67
+ # methods (because things like RendererAgg change their
68
+ # methods on the fly in order to optimise proxying down
69
+ # to the underlying C implementation).
70
+ return getattr(self._renderer, attr)
71
+
72
+ def start_rasterizing(self):
73
+ """
74
+ Enter "raster" mode. All subsequent drawing commands (until
75
+ `stop_rasterizing` is called) will be drawn with the raster backend.
76
+ """
77
+ # change the dpi of the figure temporarily.
78
+ self.figure.dpi = self.dpi
79
+
80
+ self._raster_renderer = self._raster_renderer_class(
81
+ self._width*self.dpi, self._height*self.dpi, self.dpi)
82
+ self._renderer = self._raster_renderer
83
+
84
+ if self._bbox_inches_restore: # when tight bbox is used
85
+ r = process_figure_for_rasterizing(self.figure,
86
+ self._bbox_inches_restore,
87
+ self._raster_renderer)
88
+ self._bbox_inches_restore = r
89
+
90
+ def stop_rasterizing(self):
91
+ """
92
+ Exit "raster" mode. All of the drawing that was done since
93
+ the last `start_rasterizing` call will be copied to the
94
+ vector backend by calling draw_image.
95
+ """
96
+
97
+ self._renderer = self._vector_renderer
98
+
99
+ height = self._height * self.dpi
100
+ img = np.asarray(self._raster_renderer.buffer_rgba())
101
+ slice_y, slice_x = cbook._get_nonzero_slices(img[..., 3])
102
+ cropped_img = img[slice_y, slice_x]
103
+ if cropped_img.size:
104
+ gc = self._renderer.new_gc()
105
+ # TODO: If the mixedmode resolution differs from the figure's
106
+ # dpi, the image must be scaled (dpi->_figdpi). Not all
107
+ # backends support this.
108
+ self._renderer.draw_image(
109
+ gc,
110
+ slice_x.start * self._figdpi / self.dpi,
111
+ (height - slice_y.stop) * self._figdpi / self.dpi,
112
+ cropped_img[::-1])
113
+ self._raster_renderer = None
114
+
115
+ # restore the figure dpi.
116
+ self.figure.dpi = self._figdpi
117
+
118
+ if self._bbox_inches_restore: # when tight bbox is used
119
+ r = process_figure_for_rasterizing(self.figure,
120
+ self._bbox_inches_restore,
121
+ self._vector_renderer,
122
+ self._figdpi)
123
+ self._bbox_inches_restore = r