matplotlib-rs 0.0.8__cp315-cp315-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (352) hide show
  1. docs/releases/0.0.1.md +268 -0
  2. docs/releases/0.0.2.md +69 -0
  3. docs/releases/0.0.3.md +80 -0
  4. docs/releases/0.0.4.md +73 -0
  5. docs/releases/0.0.5.md +24 -0
  6. docs/releases/0.0.6.md +24 -0
  7. docs/releases/0.0.7.md +24 -0
  8. docs/releases/0.0.8.md +16 -0
  9. licenses/LICENSE_CONTOURPY +29 -0
  10. licenses/LICENSE_CYCLER +27 -0
  11. licenses/LICENSE_DATEUTIL +54 -0
  12. licenses/LICENSE_KIWISOLVER +71 -0
  13. licenses/LICENSE_LIBWEBP +56 -0
  14. licenses/LICENSE_MATPLOTLIB +1253 -0
  15. licenses/LICENSE_PYPARSING +20 -0
  16. licenses/LICENSE_QHULL +39 -0
  17. licenses/LICENSE_SIX +18 -0
  18. matplotlib_rs/__init__.py +1683 -0
  19. matplotlib_rs/__main__.py +27 -0
  20. matplotlib_rs/_afm.py +500 -0
  21. matplotlib_rs/_animation_data.py +263 -0
  22. matplotlib_rs/_api/__init__.py +495 -0
  23. matplotlib_rs/_api/deprecation.py +534 -0
  24. matplotlib_rs/_axis_py.py +2991 -0
  25. matplotlib_rs/_blocking_input.py +31 -0
  26. matplotlib_rs/_cm.py +1500 -0
  27. matplotlib_rs/_cm_bivar.py +1289 -0
  28. matplotlib_rs/_cm_listed.py +2848 -0
  29. matplotlib_rs/_cm_multivar.py +167 -0
  30. matplotlib_rs/_color_data.py +1142 -0
  31. matplotlib_rs/_colormap.py +132 -0
  32. matplotlib_rs/_constrained_layout.py +825 -0
  33. matplotlib_rs/_contour.py +108 -0
  34. matplotlib_rs/_doc_cache.py +12214 -0
  35. matplotlib_rs/_docstring.py +142 -0
  36. matplotlib_rs/_enums.py +178 -0
  37. matplotlib_rs/_figure_rs.py +294 -0
  38. matplotlib_rs/_fontconfig_pattern.py +129 -0
  39. matplotlib_rs/_foreign.py +220 -0
  40. matplotlib_rs/_hook.py +94 -0
  41. matplotlib_rs/_image.py +160 -0
  42. matplotlib_rs/_imageio.py +229 -0
  43. matplotlib_rs/_internal_utils.py +65 -0
  44. matplotlib_rs/_kiwi.py +484 -0
  45. matplotlib_rs/_layoutgrid.py +549 -0
  46. matplotlib_rs/_live.py +192 -0
  47. matplotlib_rs/_mathtext.py +3103 -0
  48. matplotlib_rs/_mathtext_data.py +1811 -0
  49. matplotlib_rs/_mplrs.cp315-win_amd64.pyd +0 -0
  50. matplotlib_rs/_path.py +25 -0
  51. matplotlib_rs/_png.py +162 -0
  52. matplotlib_rs/_pylab_helpers.py +137 -0
  53. matplotlib_rs/_qhull.py +66 -0
  54. matplotlib_rs/_rcpush.py +84 -0
  55. matplotlib_rs/_spines_rs.py +108 -0
  56. matplotlib_rs/_style_helpers.py +52 -0
  57. matplotlib_rs/_text_helpers.py +51 -0
  58. matplotlib_rs/_tight_bbox.py +85 -0
  59. matplotlib_rs/_tight_layout.py +302 -0
  60. matplotlib_rs/_tri.py +140 -0
  61. matplotlib_rs/_type1font.py +1228 -0
  62. matplotlib_rs/_vendor/__init__.py +8 -0
  63. matplotlib_rs/_vendor/cycler.py +574 -0
  64. matplotlib_rs/_vendor/dateutil/__init__.py +27 -0
  65. matplotlib_rs/_vendor/dateutil/_common.py +44 -0
  66. matplotlib_rs/_vendor/dateutil/_tzdata_impl.py +148 -0
  67. matplotlib_rs/_vendor/dateutil/_version.py +5 -0
  68. matplotlib_rs/_vendor/dateutil/easter.py +90 -0
  69. matplotlib_rs/_vendor/dateutil/parser/__init__.py +62 -0
  70. matplotlib_rs/_vendor/dateutil/parser/_parser.py +1614 -0
  71. matplotlib_rs/_vendor/dateutil/parser/isoparser.py +417 -0
  72. matplotlib_rs/_vendor/dateutil/relativedelta.py +597 -0
  73. matplotlib_rs/_vendor/dateutil/rrule.py +1765 -0
  74. matplotlib_rs/_vendor/dateutil/tz/__init__.py +61 -0
  75. matplotlib_rs/_vendor/dateutil/tz/_common.py +420 -0
  76. matplotlib_rs/_vendor/dateutil/tz/_factories.py +81 -0
  77. matplotlib_rs/_vendor/dateutil/tz/_tzfile.py +1429 -0
  78. matplotlib_rs/_vendor/dateutil/tz/_tzpath.py +105 -0
  79. matplotlib_rs/_vendor/dateutil/tz/tz.py +1473 -0
  80. matplotlib_rs/_vendor/dateutil/tz/win.py +371 -0
  81. matplotlib_rs/_vendor/dateutil/tzwin.py +3 -0
  82. matplotlib_rs/_vendor/dateutil/utils.py +72 -0
  83. matplotlib_rs/_vendor/dateutil/zoneinfo/__init__.py +234 -0
  84. matplotlib_rs/_vendor/pyparsing/__init__.py +414 -0
  85. matplotlib_rs/_vendor/pyparsing/actions.py +265 -0
  86. matplotlib_rs/_vendor/pyparsing/common.py +571 -0
  87. matplotlib_rs/_vendor/pyparsing/core.py +6973 -0
  88. matplotlib_rs/_vendor/pyparsing/exceptions.py +354 -0
  89. matplotlib_rs/_vendor/pyparsing/helpers.py +1770 -0
  90. matplotlib_rs/_vendor/pyparsing/results.py +929 -0
  91. matplotlib_rs/_vendor/pyparsing/testing.py +399 -0
  92. matplotlib_rs/_vendor/pyparsing/unicode.py +357 -0
  93. matplotlib_rs/_vendor/pyparsing/util.py +515 -0
  94. matplotlib_rs/_vendor/pyparsing/warnings.py +11 -0
  95. matplotlib_rs/_vendor/six.py +1004 -0
  96. matplotlib_rs/animation.py +1843 -0
  97. matplotlib_rs/artist.py +2302 -0
  98. matplotlib_rs/axes/__init__.py +19 -0
  99. matplotlib_rs/axes/_axes.py +9402 -0
  100. matplotlib_rs/axes/_bar.py +185 -0
  101. matplotlib_rs/axes/_base.py +5236 -0
  102. matplotlib_rs/axes/_base_rs.py +727 -0
  103. matplotlib_rs/axes/_boxplot.py +391 -0
  104. matplotlib_rs/axes/_hist.py +99 -0
  105. matplotlib_rs/axes/_secondary_axes.py +357 -0
  106. matplotlib_rs/axis.py +1963 -0
  107. matplotlib_rs/backend_bases.py +3760 -0
  108. matplotlib_rs/backend_managers.py +388 -0
  109. matplotlib_rs/backend_tools.py +1002 -0
  110. matplotlib_rs/backends/__init__.py +6 -0
  111. matplotlib_rs/backends/_backend_pdf_ps.py +451 -0
  112. matplotlib_rs/backends/backend_agg.py +552 -0
  113. matplotlib_rs/backends/backend_mixed.py +123 -0
  114. matplotlib_rs/backends/backend_pdf.py +2711 -0
  115. matplotlib_rs/backends/backend_pgf.py +1031 -0
  116. matplotlib_rs/backends/backend_ps.py +1491 -0
  117. matplotlib_rs/backends/backend_svg.py +1395 -0
  118. matplotlib_rs/backends/backend_template.py +214 -0
  119. matplotlib_rs/backends/registry.py +423 -0
  120. matplotlib_rs/bezier.py +691 -0
  121. matplotlib_rs/category.py +236 -0
  122. matplotlib_rs/cbook.py +2762 -0
  123. matplotlib_rs/cm.py +251 -0
  124. matplotlib_rs/collections.py +2711 -0
  125. matplotlib_rs/colorbar.py +1586 -0
  126. matplotlib_rs/colorizer.py +909 -0
  127. matplotlib_rs/colors.py +4278 -0
  128. matplotlib_rs/container.py +256 -0
  129. matplotlib_rs/contour.py +1756 -0
  130. matplotlib_rs/dates.py +1847 -0
  131. matplotlib_rs/dviread.py +1386 -0
  132. matplotlib_rs/figure.py +3815 -0
  133. matplotlib_rs/font_manager.py +1855 -0
  134. matplotlib_rs/ft2font.py +515 -0
  135. matplotlib_rs/gridspec.py +808 -0
  136. matplotlib_rs/hatch.py +244 -0
  137. matplotlib_rs/image.py +1863 -0
  138. matplotlib_rs/inset.py +291 -0
  139. matplotlib_rs/layout_engine.py +310 -0
  140. matplotlib_rs/legend.py +1480 -0
  141. matplotlib_rs/legend_handler.py +812 -0
  142. matplotlib_rs/lines.py +1886 -0
  143. matplotlib_rs/markers.py +908 -0
  144. matplotlib_rs/mathtext.py +141 -0
  145. matplotlib_rs/mlab.py +959 -0
  146. matplotlib_rs/mpl-data/fonts/ttf/DejaVuSans-Bold.ttf +0 -0
  147. matplotlib_rs/mpl-data/fonts/ttf/DejaVuSans-BoldOblique.ttf +0 -0
  148. matplotlib_rs/mpl-data/fonts/ttf/DejaVuSans-Oblique.ttf +0 -0
  149. matplotlib_rs/mpl-data/fonts/ttf/DejaVuSans.ttf +0 -0
  150. matplotlib_rs/mpl-data/fonts/ttf/DejaVuSansDisplay.ttf +0 -0
  151. matplotlib_rs/mpl-data/fonts/ttf/DejaVuSansMono-Bold.ttf +0 -0
  152. matplotlib_rs/mpl-data/fonts/ttf/DejaVuSansMono-BoldOblique.ttf +0 -0
  153. matplotlib_rs/mpl-data/fonts/ttf/DejaVuSansMono-Oblique.ttf +0 -0
  154. matplotlib_rs/mpl-data/fonts/ttf/DejaVuSansMono.ttf +0 -0
  155. matplotlib_rs/mpl-data/fonts/ttf/DejaVuSerif-Bold.ttf +0 -0
  156. matplotlib_rs/mpl-data/fonts/ttf/DejaVuSerif-BoldItalic.ttf +0 -0
  157. matplotlib_rs/mpl-data/fonts/ttf/DejaVuSerif-Italic.ttf +0 -0
  158. matplotlib_rs/mpl-data/fonts/ttf/DejaVuSerif.ttf +0 -0
  159. matplotlib_rs/mpl-data/fonts/ttf/DejaVuSerifDisplay.ttf +0 -0
  160. matplotlib_rs/mpl-data/fonts/ttf/LICENSE_DEJAVU +99 -0
  161. matplotlib_rs/mpl-data/fonts/ttf/LICENSE_STIX +124 -0
  162. matplotlib_rs/mpl-data/fonts/ttf/LastResortHE-Regular.ttf +0 -0
  163. matplotlib_rs/mpl-data/fonts/ttf/STIXGeneral.ttf +0 -0
  164. matplotlib_rs/mpl-data/fonts/ttf/STIXGeneralBol.ttf +0 -0
  165. matplotlib_rs/mpl-data/fonts/ttf/STIXGeneralBolIta.ttf +0 -0
  166. matplotlib_rs/mpl-data/fonts/ttf/STIXGeneralItalic.ttf +0 -0
  167. matplotlib_rs/mpl-data/fonts/ttf/STIXNonUni.ttf +0 -0
  168. matplotlib_rs/mpl-data/fonts/ttf/STIXNonUniBol.ttf +0 -0
  169. matplotlib_rs/mpl-data/fonts/ttf/STIXNonUniBolIta.ttf +0 -0
  170. matplotlib_rs/mpl-data/fonts/ttf/STIXNonUniIta.ttf +0 -0
  171. matplotlib_rs/mpl-data/fonts/ttf/STIXSizFiveSymReg.ttf +0 -0
  172. matplotlib_rs/mpl-data/fonts/ttf/STIXSizFourSymBol.ttf +0 -0
  173. matplotlib_rs/mpl-data/fonts/ttf/STIXSizFourSymReg.ttf +0 -0
  174. matplotlib_rs/mpl-data/fonts/ttf/STIXSizOneSymBol.ttf +0 -0
  175. matplotlib_rs/mpl-data/fonts/ttf/STIXSizOneSymReg.ttf +0 -0
  176. matplotlib_rs/mpl-data/fonts/ttf/STIXSizThreeSymBol.ttf +0 -0
  177. matplotlib_rs/mpl-data/fonts/ttf/STIXSizThreeSymReg.ttf +0 -0
  178. matplotlib_rs/mpl-data/fonts/ttf/STIXSizTwoSymBol.ttf +0 -0
  179. matplotlib_rs/mpl-data/fonts/ttf/STIXSizTwoSymReg.ttf +0 -0
  180. matplotlib_rs/mpl-data/fonts/ttf/cmb10.ttf +0 -0
  181. matplotlib_rs/mpl-data/fonts/ttf/cmex10.ttf +0 -0
  182. matplotlib_rs/mpl-data/fonts/ttf/cmmi10.ttf +0 -0
  183. matplotlib_rs/mpl-data/fonts/ttf/cmr10.ttf +0 -0
  184. matplotlib_rs/mpl-data/fonts/ttf/cmss10.ttf +0 -0
  185. matplotlib_rs/mpl-data/fonts/ttf/cmsy10.ttf +0 -0
  186. matplotlib_rs/mpl-data/fonts/ttf/cmti10.ttf +0 -0
  187. matplotlib_rs/mpl-data/fonts/ttf/cmtt10.ttf +0 -0
  188. matplotlib_rs/mpl-data/images/back-symbolic.svg +46 -0
  189. matplotlib_rs/mpl-data/images/back.pdf +0 -0
  190. matplotlib_rs/mpl-data/images/back.png +0 -0
  191. matplotlib_rs/mpl-data/images/back.svg +46 -0
  192. matplotlib_rs/mpl-data/images/back_large.png +0 -0
  193. matplotlib_rs/mpl-data/images/filesave-symbolic.svg +68 -0
  194. matplotlib_rs/mpl-data/images/filesave.pdf +72 -0
  195. matplotlib_rs/mpl-data/images/filesave.png +0 -0
  196. matplotlib_rs/mpl-data/images/filesave.svg +68 -0
  197. matplotlib_rs/mpl-data/images/filesave_large.png +0 -0
  198. matplotlib_rs/mpl-data/images/forward-symbolic.svg +46 -0
  199. matplotlib_rs/mpl-data/images/forward.pdf +0 -0
  200. matplotlib_rs/mpl-data/images/forward.png +0 -0
  201. matplotlib_rs/mpl-data/images/forward.svg +46 -0
  202. matplotlib_rs/mpl-data/images/forward_large.png +0 -0
  203. matplotlib_rs/mpl-data/images/hand.pdf +0 -0
  204. matplotlib_rs/mpl-data/images/hand.png +0 -0
  205. matplotlib_rs/mpl-data/images/hand.svg +130 -0
  206. matplotlib_rs/mpl-data/images/help-symbolic.svg +52 -0
  207. matplotlib_rs/mpl-data/images/help.pdf +71 -0
  208. matplotlib_rs/mpl-data/images/help.png +0 -0
  209. matplotlib_rs/mpl-data/images/help.svg +52 -0
  210. matplotlib_rs/mpl-data/images/help_large.png +0 -0
  211. matplotlib_rs/mpl-data/images/home-symbolic.svg +59 -0
  212. matplotlib_rs/mpl-data/images/home.pdf +0 -0
  213. matplotlib_rs/mpl-data/images/home.png +0 -0
  214. matplotlib_rs/mpl-data/images/home.svg +59 -0
  215. matplotlib_rs/mpl-data/images/home_large.png +0 -0
  216. matplotlib_rs/mpl-data/images/matplotlib.pdf +0 -0
  217. matplotlib_rs/mpl-data/images/matplotlib.png +0 -0
  218. matplotlib_rs/mpl-data/images/matplotlib.svg +3171 -0
  219. matplotlib_rs/mpl-data/images/matplotlib_large.png +0 -0
  220. matplotlib_rs/mpl-data/images/move-symbolic.svg +73 -0
  221. matplotlib_rs/mpl-data/images/move.pdf +0 -0
  222. matplotlib_rs/mpl-data/images/move.png +0 -0
  223. matplotlib_rs/mpl-data/images/move.svg +73 -0
  224. matplotlib_rs/mpl-data/images/move_large.png +0 -0
  225. matplotlib_rs/mpl-data/images/qt4_editor_options.pdf +0 -0
  226. matplotlib_rs/mpl-data/images/qt4_editor_options.png +0 -0
  227. matplotlib_rs/mpl-data/images/qt4_editor_options.svg +48 -0
  228. matplotlib_rs/mpl-data/images/qt4_editor_options_large.png +0 -0
  229. matplotlib_rs/mpl-data/images/subplots-symbolic.svg +81 -0
  230. matplotlib_rs/mpl-data/images/subplots.pdf +0 -0
  231. matplotlib_rs/mpl-data/images/subplots.png +0 -0
  232. matplotlib_rs/mpl-data/images/subplots.svg +81 -0
  233. matplotlib_rs/mpl-data/images/subplots_large.png +0 -0
  234. matplotlib_rs/mpl-data/images/zoom_to_rect-symbolic.svg +40 -0
  235. matplotlib_rs/mpl-data/images/zoom_to_rect.pdf +69 -0
  236. matplotlib_rs/mpl-data/images/zoom_to_rect.png +0 -0
  237. matplotlib_rs/mpl-data/images/zoom_to_rect.svg +40 -0
  238. matplotlib_rs/mpl-data/images/zoom_to_rect_large.png +0 -0
  239. matplotlib_rs/mpl-data/kpsewhich.lua +4 -0
  240. matplotlib_rs/mpl-data/matplotlibrc +849 -0
  241. matplotlib_rs/mpl-data/plot_directive/plot_directive.css +16 -0
  242. matplotlib_rs/mpl-data/sample_data/Minduka_Present_Blue_Pack.png +0 -0
  243. matplotlib_rs/mpl-data/sample_data/README.txt +2 -0
  244. matplotlib_rs/mpl-data/sample_data/Stocks.csv +526 -0
  245. matplotlib_rs/mpl-data/sample_data/axes_grid/bivariate_normal.npy +0 -0
  246. matplotlib_rs/mpl-data/sample_data/data_x_x2_x3.csv +11 -0
  247. matplotlib_rs/mpl-data/sample_data/eeg.dat +0 -0
  248. matplotlib_rs/mpl-data/sample_data/embedding_in_wx3.xrc +65 -0
  249. matplotlib_rs/mpl-data/sample_data/goog.npz +0 -0
  250. matplotlib_rs/mpl-data/sample_data/grace_hopper.jpg +0 -0
  251. matplotlib_rs/mpl-data/sample_data/jacksboro_fault_dem.npz +0 -0
  252. matplotlib_rs/mpl-data/sample_data/logo2.png +0 -0
  253. matplotlib_rs/mpl-data/sample_data/membrane.dat +0 -0
  254. matplotlib_rs/mpl-data/sample_data/msft.csv +66 -0
  255. matplotlib_rs/mpl-data/sample_data/s1045.ima.gz +0 -0
  256. matplotlib_rs/mpl-data/sample_data/topobathy.npz +0 -0
  257. matplotlib_rs/mpl-data/stylelib/Solarize_Light2.mplstyle +53 -0
  258. matplotlib_rs/mpl-data/stylelib/_classic_test_patch.mplstyle +8 -0
  259. matplotlib_rs/mpl-data/stylelib/_mpl-gallery-nogrid.mplstyle +19 -0
  260. matplotlib_rs/mpl-data/stylelib/_mpl-gallery.mplstyle +19 -0
  261. matplotlib_rs/mpl-data/stylelib/bmh.mplstyle +27 -0
  262. matplotlib_rs/mpl-data/stylelib/classic.mplstyle +491 -0
  263. matplotlib_rs/mpl-data/stylelib/dark_background.mplstyle +26 -0
  264. matplotlib_rs/mpl-data/stylelib/fast.mplstyle +11 -0
  265. matplotlib_rs/mpl-data/stylelib/fivethirtyeight.mplstyle +37 -0
  266. matplotlib_rs/mpl-data/stylelib/ggplot.mplstyle +39 -0
  267. matplotlib_rs/mpl-data/stylelib/grayscale.mplstyle +29 -0
  268. matplotlib_rs/mpl-data/stylelib/petroff10.mplstyle +5 -0
  269. matplotlib_rs/mpl-data/stylelib/petroff6.mplstyle +5 -0
  270. matplotlib_rs/mpl-data/stylelib/petroff8.mplstyle +5 -0
  271. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-bright.mplstyle +3 -0
  272. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-colorblind.mplstyle +3 -0
  273. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-dark-palette.mplstyle +3 -0
  274. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-dark.mplstyle +30 -0
  275. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-darkgrid.mplstyle +30 -0
  276. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-deep.mplstyle +3 -0
  277. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-muted.mplstyle +3 -0
  278. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-notebook.mplstyle +21 -0
  279. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-paper.mplstyle +21 -0
  280. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-pastel.mplstyle +3 -0
  281. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-poster.mplstyle +21 -0
  282. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-talk.mplstyle +21 -0
  283. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-ticks.mplstyle +30 -0
  284. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-white.mplstyle +30 -0
  285. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-whitegrid.mplstyle +30 -0
  286. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8.mplstyle +57 -0
  287. matplotlib_rs/mpl-data/stylelib/tableau-colorblind10.mplstyle +3 -0
  288. matplotlib_rs/mpl_toolkits/__init__.py +3 -0
  289. matplotlib_rs/mpl_toolkits/axes_grid1/__init__.py +11 -0
  290. matplotlib_rs/mpl_toolkits/axes_grid1/anchored_artists.py +415 -0
  291. matplotlib_rs/mpl_toolkits/axes_grid1/axes_divider.py +619 -0
  292. matplotlib_rs/mpl_toolkits/axes_grid1/axes_grid.py +565 -0
  293. matplotlib_rs/mpl_toolkits/axes_grid1/axes_rgb.py +158 -0
  294. matplotlib_rs/mpl_toolkits/axes_grid1/axes_size.py +272 -0
  295. matplotlib_rs/mpl_toolkits/axes_grid1/inset_locator.py +525 -0
  296. matplotlib_rs/mpl_toolkits/axes_grid1/mpl_axes.py +129 -0
  297. matplotlib_rs/mpl_toolkits/axes_grid1/parasite_axes.py +261 -0
  298. matplotlib_rs/mpl_toolkits/axisartist/__init__.py +15 -0
  299. matplotlib_rs/mpl_toolkits/axisartist/angle_helper.py +396 -0
  300. matplotlib_rs/mpl_toolkits/axisartist/axes_divider.py +3 -0
  301. matplotlib_rs/mpl_toolkits/axisartist/axis_artist.py +1148 -0
  302. matplotlib_rs/mpl_toolkits/axisartist/axisline_style.py +193 -0
  303. matplotlib_rs/mpl_toolkits/axisartist/axislines.py +475 -0
  304. matplotlib_rs/mpl_toolkits/axisartist/floating_axes.py +265 -0
  305. matplotlib_rs/mpl_toolkits/axisartist/grid_finder.py +329 -0
  306. matplotlib_rs/mpl_toolkits/axisartist/grid_helper_curvelinear.py +353 -0
  307. matplotlib_rs/mpl_toolkits/axisartist/parasite_axes.py +8 -0
  308. matplotlib_rs/mpl_toolkits/mplot3d/__init__.py +4 -0
  309. matplotlib_rs/mpl_toolkits/mplot3d/art3d.py +1758 -0
  310. matplotlib_rs/mpl_toolkits/mplot3d/axes3d.py +4462 -0
  311. matplotlib_rs/mpl_toolkits/mplot3d/axis3d.py +807 -0
  312. matplotlib_rs/mpl_toolkits/mplot3d/proj3d.py +270 -0
  313. matplotlib_rs/offsetbox.py +1726 -0
  314. matplotlib_rs/patches.py +5049 -0
  315. matplotlib_rs/path.py +1147 -0
  316. matplotlib_rs/patheffects.py +512 -0
  317. matplotlib_rs/projections/__init__.py +126 -0
  318. matplotlib_rs/projections/geo.py +512 -0
  319. matplotlib_rs/projections/polar.py +1518 -0
  320. matplotlib_rs/pylab.py +68 -0
  321. matplotlib_rs/pyplot.py +4834 -0
  322. matplotlib_rs/quiver.py +1236 -0
  323. matplotlib_rs/rcsetup.py +3435 -0
  324. matplotlib_rs/sankey.py +815 -0
  325. matplotlib_rs/scale.py +1002 -0
  326. matplotlib_rs/spines.py +618 -0
  327. matplotlib_rs/stackplot.py +144 -0
  328. matplotlib_rs/streamplot.py +768 -0
  329. matplotlib_rs/style/__init__.py +269 -0
  330. matplotlib_rs/style/core.py +28 -0
  331. matplotlib_rs/table.py +860 -0
  332. matplotlib_rs/texmanager.py +375 -0
  333. matplotlib_rs/text.py +2412 -0
  334. matplotlib_rs/textpath.py +377 -0
  335. matplotlib_rs/ticker.py +3111 -0
  336. matplotlib_rs/transforms.py +3069 -0
  337. matplotlib_rs/tri/__init__.py +24 -0
  338. matplotlib_rs/tri/_triangulation.py +248 -0
  339. matplotlib_rs/tri/_tricontour.py +271 -0
  340. matplotlib_rs/tri/_trifinder.py +97 -0
  341. matplotlib_rs/tri/_triinterpolate.py +1575 -0
  342. matplotlib_rs/tri/_tripcolor.py +170 -0
  343. matplotlib_rs/tri/_triplot.py +87 -0
  344. matplotlib_rs/tri/_trirefine.py +308 -0
  345. matplotlib_rs/tri/_tritools.py +264 -0
  346. matplotlib_rs/typing.py +597 -0
  347. matplotlib_rs/units.py +196 -0
  348. matplotlib_rs/widgets.py +4455 -0
  349. matplotlib_rs-0.0.8.dist-info/METADATA +392 -0
  350. matplotlib_rs-0.0.8.dist-info/RECORD +352 -0
  351. matplotlib_rs-0.0.8.dist-info/WHEEL +4 -0
  352. matplotlib_rs-0.0.8.dist-info/sboms/matplotlib-rs.cyclonedx.json +4390 -0
@@ -0,0 +1,815 @@
1
+ # Vendored from matplotlib 3.11 (see licenses/LICENSE_MATPLOTLIB), adapted for matplotlib_rs.
2
+ """
3
+ Module for creating Sankey diagrams using Matplotlib.
4
+ """
5
+
6
+ import logging
7
+ from types import SimpleNamespace
8
+
9
+ import numpy as np
10
+
11
+ import matplotlib_rs as mpl
12
+ from matplotlib_rs.path import Path
13
+ from matplotlib_rs.patches import PathPatch
14
+ from matplotlib_rs.transforms import Affine2D
15
+ from matplotlib_rs import _docstring
16
+
17
+ _log = logging.getLogger(__name__)
18
+
19
+ __author__ = "Kevin L. Davies"
20
+ __credits__ = ["Yannick Copin"]
21
+ __license__ = "BSD"
22
+ __version__ = "2011/09/16"
23
+
24
+ # Angles [deg/90]
25
+ RIGHT = 0
26
+ UP = 1
27
+ # LEFT = 2
28
+ DOWN = 3
29
+
30
+
31
+ class Sankey:
32
+ """
33
+ Sankey diagram.
34
+
35
+ Sankey diagrams are a specific type of flow diagram, in which
36
+ the width of the arrows is shown proportionally to the flow
37
+ quantity. They are typically used to visualize energy or
38
+ material or cost transfers between processes.
39
+ `Wikipedia (6/1/2011) <https://en.wikipedia.org/wiki/Sankey_diagram>`_
40
+
41
+ """
42
+
43
+ def __init__(self, ax=None, scale=1.0, unit='', format='%G', gap=0.25,
44
+ radius=0.1, shoulder=0.03, offset=0.15, head_angle=100,
45
+ margin=0.4, tolerance=1e-6, **kwargs):
46
+ """
47
+ Create a new Sankey instance.
48
+
49
+ The optional arguments listed below are applied to all subdiagrams so
50
+ that there is consistent alignment and formatting.
51
+
52
+ In order to draw a complex Sankey diagram, create an instance of
53
+ `Sankey` by calling it without any kwargs::
54
+
55
+ sankey = Sankey()
56
+
57
+ Then add simple Sankey sub-diagrams::
58
+
59
+ sankey.add() # 1
60
+ sankey.add() # 2
61
+ #...
62
+ sankey.add() # n
63
+
64
+ Finally, create the full diagram::
65
+
66
+ sankey.finish()
67
+
68
+ Or, instead, simply daisy-chain those calls::
69
+
70
+ Sankey().add().add... .add().finish()
71
+
72
+ Other Parameters
73
+ ----------------
74
+ ax : `~matplotlib.axes.Axes`
75
+ Axes onto which the data should be plotted. If *ax* isn't
76
+ provided, new Axes will be created.
77
+ scale : float
78
+ Scaling factor for the flows. *scale* sizes the width of the paths
79
+ in order to maintain proper layout. The same scale is applied to
80
+ all subdiagrams. The value should be chosen such that the product
81
+ of the scale and the sum of the inputs is approximately 1.0 (and
82
+ the product of the scale and the sum of the outputs is
83
+ approximately -1.0).
84
+ unit : str
85
+ The physical unit associated with the flow quantities. If *unit*
86
+ is None, then none of the quantities are labeled.
87
+ format : str or callable
88
+ A Python number formatting string or callable used to label the
89
+ flows with their quantities (i.e., a number times a unit, where the
90
+ unit is given). If a format string is given, the label will be
91
+ ``format % quantity``. If a callable is given, it will be called
92
+ with ``quantity`` as an argument.
93
+ gap : float
94
+ Space between paths that break in/break away to/from the top or
95
+ bottom.
96
+ radius : float
97
+ Inner radius of the vertical paths.
98
+ shoulder : float
99
+ Size of the shoulders of output arrows.
100
+ offset : float
101
+ Text offset (from the dip or tip of the arrow).
102
+ head_angle : float
103
+ Angle, in degrees, of the arrow heads (and negative of the angle of
104
+ the tails).
105
+ margin : float
106
+ Minimum space between Sankey outlines and the edge of the plot
107
+ area.
108
+ tolerance : float
109
+ Acceptable maximum of the magnitude of the sum of flows. The
110
+ magnitude of the sum of connected flows cannot be greater than
111
+ *tolerance*.
112
+ **kwargs
113
+ Any additional keyword arguments will be passed to `add`, which
114
+ will create the first subdiagram.
115
+
116
+ See Also
117
+ --------
118
+ Sankey.add
119
+ Sankey.finish
120
+
121
+ Examples
122
+ --------
123
+ .. plot:: gallery/specialty_plots/sankey_basics.py
124
+ """
125
+ # Check the arguments.
126
+ if gap < 0:
127
+ raise ValueError(
128
+ "'gap' is negative, which is not allowed because it would "
129
+ "cause the paths to overlap")
130
+ if radius > gap:
131
+ raise ValueError(
132
+ "'radius' is greater than 'gap', which is not allowed because "
133
+ "it would cause the paths to overlap")
134
+ if head_angle < 0:
135
+ raise ValueError(
136
+ "'head_angle' is negative, which is not allowed because it "
137
+ "would cause inputs to look like outputs and vice versa")
138
+ if tolerance < 0:
139
+ raise ValueError(
140
+ "'tolerance' is negative, but it must be a magnitude")
141
+
142
+ # Create Axes if necessary.
143
+ if ax is None:
144
+ import matplotlib_rs.pyplot as plt
145
+ fig = plt.figure()
146
+ ax = fig.add_subplot(1, 1, 1, xticks=[], yticks=[])
147
+
148
+ self.diagrams = []
149
+
150
+ # Store the inputs.
151
+ self.ax = ax
152
+ self.unit = unit
153
+ self.format = format
154
+ self.scale = scale
155
+ self.gap = gap
156
+ self.radius = radius
157
+ self.shoulder = shoulder
158
+ self.offset = offset
159
+ self.margin = margin
160
+ self.pitch = np.tan(np.pi * (1 - head_angle / 180.0) / 2.0)
161
+ self.tolerance = tolerance
162
+
163
+ # Initialize the vertices of tight box around the diagram(s).
164
+ self.extent = np.array((np.inf, -np.inf, np.inf, -np.inf))
165
+
166
+ # If there are any kwargs, create the first subdiagram.
167
+ if len(kwargs):
168
+ self.add(**kwargs)
169
+
170
+ def _arc(self, quadrant=0, cw=True, radius=1, center=(0, 0)):
171
+ """
172
+ Return the codes and vertices for a rotated, scaled, and translated
173
+ 90 degree arc.
174
+
175
+ Other Parameters
176
+ ----------------
177
+ quadrant : {0, 1, 2, 3}, default: 0
178
+ Uses 0-based indexing (0, 1, 2, or 3).
179
+ cw : bool, default: True
180
+ If True, the arc vertices are produced clockwise; counter-clockwise
181
+ otherwise.
182
+ radius : float, default: 1
183
+ The radius of the arc.
184
+ center : (float, float), default: (0, 0)
185
+ (x, y) tuple of the arc's center.
186
+ """
187
+ # Note: It would be possible to use matplotlib's transforms to rotate,
188
+ # scale, and translate the arc, but since the angles are discrete,
189
+ # it's just as easy and maybe more efficient to do it here.
190
+ ARC_CODES = [Path.LINETO,
191
+ Path.CURVE4,
192
+ Path.CURVE4,
193
+ Path.CURVE4,
194
+ Path.CURVE4,
195
+ Path.CURVE4,
196
+ Path.CURVE4]
197
+ # Vertices of a cubic Bezier curve approximating a 90 deg arc
198
+ # These can be determined by Path.arc(0, 90).
199
+ ARC_VERTICES = np.array([[1.00000000e+00, 0.00000000e+00],
200
+ [1.00000000e+00, 2.65114773e-01],
201
+ [8.94571235e-01, 5.19642327e-01],
202
+ [7.07106781e-01, 7.07106781e-01],
203
+ [5.19642327e-01, 8.94571235e-01],
204
+ [2.65114773e-01, 1.00000000e+00],
205
+ # Insignificant
206
+ # [6.12303177e-17, 1.00000000e+00]])
207
+ [0.00000000e+00, 1.00000000e+00]])
208
+ if quadrant in (0, 2):
209
+ if cw:
210
+ vertices = ARC_VERTICES
211
+ else:
212
+ vertices = ARC_VERTICES[:, ::-1] # Swap x and y.
213
+ else: # 1, 3
214
+ # Negate x.
215
+ if cw:
216
+ # Swap x and y.
217
+ vertices = np.column_stack((-ARC_VERTICES[:, 1],
218
+ ARC_VERTICES[:, 0]))
219
+ else:
220
+ vertices = np.column_stack((-ARC_VERTICES[:, 0],
221
+ ARC_VERTICES[:, 1]))
222
+ if quadrant > 1:
223
+ radius = -radius # Rotate 180 deg.
224
+ return list(zip(ARC_CODES, radius * vertices +
225
+ np.tile(center, (ARC_VERTICES.shape[0], 1))))
226
+
227
+ def _add_input(self, path, angle, flow, length):
228
+ """
229
+ Add an input to a path and return its tip and label locations.
230
+ """
231
+ if angle is None:
232
+ return [0, 0], [0, 0]
233
+ else:
234
+ x, y = path[-1][1] # Use the last point as a reference.
235
+ dipdepth = (flow / 2) * self.pitch
236
+ if angle == RIGHT:
237
+ x -= length
238
+ dip = [x + dipdepth, y + flow / 2.0]
239
+ path.extend([(Path.LINETO, [x, y]),
240
+ (Path.LINETO, dip),
241
+ (Path.LINETO, [x, y + flow]),
242
+ (Path.LINETO, [x + self.gap, y + flow])])
243
+ label_location = [dip[0] - self.offset, dip[1]]
244
+ else: # Vertical
245
+ x -= self.gap
246
+ if angle == UP:
247
+ sign = 1
248
+ else:
249
+ sign = -1
250
+
251
+ dip = [x - flow / 2, y - sign * (length - dipdepth)]
252
+ if angle == DOWN:
253
+ quadrant = 2
254
+ else:
255
+ quadrant = 1
256
+
257
+ # Inner arc isn't needed if inner radius is zero
258
+ if self.radius:
259
+ path.extend(self._arc(quadrant=quadrant,
260
+ cw=angle == UP,
261
+ radius=self.radius,
262
+ center=(x + self.radius,
263
+ y - sign * self.radius)))
264
+ else:
265
+ path.append((Path.LINETO, [x, y]))
266
+ path.extend([(Path.LINETO, [x, y - sign * length]),
267
+ (Path.LINETO, dip),
268
+ (Path.LINETO, [x - flow, y - sign * length])])
269
+ path.extend(self._arc(quadrant=quadrant,
270
+ cw=angle == DOWN,
271
+ radius=flow + self.radius,
272
+ center=(x + self.radius,
273
+ y - sign * self.radius)))
274
+ path.append((Path.LINETO, [x - flow, y + sign * flow]))
275
+ label_location = [dip[0], dip[1] - sign * self.offset]
276
+
277
+ return dip, label_location
278
+
279
+ def _add_output(self, path, angle, flow, length):
280
+ """
281
+ Append an output to a path and return its tip and label locations.
282
+
283
+ .. note:: *flow* is negative for an output.
284
+ """
285
+ if angle is None:
286
+ return [0, 0], [0, 0]
287
+ else:
288
+ x, y = path[-1][1] # Use the last point as a reference.
289
+ tipheight = (self.shoulder - flow / 2) * self.pitch
290
+ if angle == RIGHT:
291
+ x += length
292
+ tip = [x + tipheight, y + flow / 2.0]
293
+ path.extend([(Path.LINETO, [x, y]),
294
+ (Path.LINETO, [x, y + self.shoulder]),
295
+ (Path.LINETO, tip),
296
+ (Path.LINETO, [x, y - self.shoulder + flow]),
297
+ (Path.LINETO, [x, y + flow]),
298
+ (Path.LINETO, [x - self.gap, y + flow])])
299
+ label_location = [tip[0] + self.offset, tip[1]]
300
+ else: # Vertical
301
+ x += self.gap
302
+ if angle == UP:
303
+ sign, quadrant = 1, 3
304
+ else:
305
+ sign, quadrant = -1, 0
306
+
307
+ tip = [x - flow / 2.0, y + sign * (length + tipheight)]
308
+ # Inner arc isn't needed if inner radius is zero
309
+ if self.radius:
310
+ path.extend(self._arc(quadrant=quadrant,
311
+ cw=angle == UP,
312
+ radius=self.radius,
313
+ center=(x - self.radius,
314
+ y + sign * self.radius)))
315
+ else:
316
+ path.append((Path.LINETO, [x, y]))
317
+ path.extend([(Path.LINETO, [x, y + sign * length]),
318
+ (Path.LINETO, [x - self.shoulder,
319
+ y + sign * length]),
320
+ (Path.LINETO, tip),
321
+ (Path.LINETO, [x + self.shoulder - flow,
322
+ y + sign * length]),
323
+ (Path.LINETO, [x - flow, y + sign * length])])
324
+ path.extend(self._arc(quadrant=quadrant,
325
+ cw=angle == DOWN,
326
+ radius=self.radius - flow,
327
+ center=(x - self.radius,
328
+ y + sign * self.radius)))
329
+ path.append((Path.LINETO, [x - flow, y + sign * flow]))
330
+ label_location = [tip[0], tip[1] + sign * self.offset]
331
+ return tip, label_location
332
+
333
+ def _revert(self, path, first_action=Path.LINETO):
334
+ """
335
+ A path is not simply reversible by path[::-1] since the code
336
+ specifies an action to take from the **previous** point.
337
+ """
338
+ reverse_path = []
339
+ next_code = first_action
340
+ for code, position in path[::-1]:
341
+ reverse_path.append((next_code, position))
342
+ next_code = code
343
+ return reverse_path
344
+ # This might be more efficient, but it fails because 'tuple' object
345
+ # doesn't support item assignment:
346
+ # path[1] = path[1][-1:0:-1]
347
+ # path[1][0] = first_action
348
+ # path[2] = path[2][::-1]
349
+ # return path
350
+
351
+ @_docstring.interpd
352
+ def add(self, patchlabel='', flows=None, orientations=None, labels='',
353
+ trunklength=1.0, pathlengths=0.25, prior=None, connect=(0, 0),
354
+ rotation=0, **kwargs):
355
+ """
356
+ Add a simple Sankey diagram with flows at the same hierarchical level.
357
+
358
+ Parameters
359
+ ----------
360
+ patchlabel : str
361
+ Label to be placed at the center of the diagram.
362
+ Note that *label* (not *patchlabel*) can be passed as keyword
363
+ argument to create an entry in the legend.
364
+
365
+ flows : list of float
366
+ Array of flow values. By convention, inputs are positive and
367
+ outputs are negative.
368
+
369
+ Flows are placed along the top of the diagram from the inside out
370
+ in order of their index within *flows*. They are placed along the
371
+ sides of the diagram from the top down and along the bottom from
372
+ the outside in.
373
+
374
+ If the sum of the inputs and outputs is
375
+ nonzero, the discrepancy will appear as a cubic Bézier curve along
376
+ the top and bottom edges of the trunk.
377
+
378
+ orientations : list of {-1, 0, 1}
379
+ List of orientations of the flows (or a single orientation to be
380
+ used for all flows). Valid values are 0 (inputs from
381
+ the left, outputs to the right), 1 (from and to the top) or -1
382
+ (from and to the bottom).
383
+
384
+ labels : list of (str or None)
385
+ List of labels for the flows (or a single label to be used for all
386
+ flows). Each label may be *None* (no label), or a labeling string.
387
+ If an entry is a (possibly empty) string, then the quantity for the
388
+ corresponding flow will be shown below the string. However, if
389
+ the *unit* of the main diagram is None, then quantities are never
390
+ shown, regardless of the value of this argument.
391
+
392
+ trunklength : float
393
+ Length between the bases of the input and output groups (in
394
+ data-space units).
395
+
396
+ pathlengths : list of float
397
+ List of lengths of the vertical arrows before break-in or after
398
+ break-away. If a single value is given, then it will be applied to
399
+ the first (inside) paths on the top and bottom, and the length of
400
+ all other arrows will be justified accordingly. The *pathlengths*
401
+ are not applied to the horizontal inputs and outputs.
402
+
403
+ prior : int
404
+ Index of the prior diagram to which this diagram should be
405
+ connected.
406
+
407
+ connect : (int, int)
408
+ A (prior, this) tuple indexing the flow of the prior diagram and
409
+ the flow of this diagram which should be connected. If this is the
410
+ first diagram or *prior* is *None*, *connect* will be ignored.
411
+
412
+ rotation : float
413
+ Angle of rotation of the diagram in degrees. The interpretation of
414
+ the *orientations* argument will be rotated accordingly (e.g., if
415
+ *rotation* == 90, an *orientations* entry of 1 means to/from the
416
+ left). *rotation* is ignored if this diagram is connected to an
417
+ existing one (using *prior* and *connect*).
418
+
419
+ Returns
420
+ -------
421
+ Sankey
422
+ The current `.Sankey` instance.
423
+
424
+ Other Parameters
425
+ ----------------
426
+ **kwargs
427
+ Additional keyword arguments set `matplotlib.patches.PathPatch`
428
+ properties, listed below. For example, one may want to use
429
+ ``fill=False`` or ``label="A legend entry"``.
430
+
431
+ %(Patch:kwdoc)s
432
+
433
+ See Also
434
+ --------
435
+ Sankey.finish
436
+ """
437
+ # Check and preprocess the arguments.
438
+ flows = np.array([1.0, -1.0]) if flows is None else np.array(flows)
439
+ n = flows.shape[0] # Number of flows
440
+ if rotation is None:
441
+ rotation = 0
442
+ else:
443
+ # In the code below, angles are expressed in deg/90.
444
+ rotation /= 90.0
445
+ if orientations is None:
446
+ orientations = 0
447
+ try:
448
+ orientations = np.broadcast_to(orientations, n)
449
+ except ValueError:
450
+ raise ValueError(
451
+ f"The shapes of 'flows' {np.shape(flows)} and 'orientations' "
452
+ f"{np.shape(orientations)} are incompatible"
453
+ ) from None
454
+ try:
455
+ labels = np.broadcast_to(labels, n)
456
+ except ValueError:
457
+ raise ValueError(
458
+ f"The shapes of 'flows' {np.shape(flows)} and 'labels' "
459
+ f"{np.shape(labels)} are incompatible"
460
+ ) from None
461
+ if trunklength < 0:
462
+ raise ValueError(
463
+ "'trunklength' is negative, which is not allowed because it "
464
+ "would cause poor layout")
465
+ if abs(np.sum(flows)) > self.tolerance:
466
+ _log.info("The sum of the flows is nonzero (%f; patchlabel=%r); "
467
+ "is the system not at steady state?",
468
+ np.sum(flows), patchlabel)
469
+ scaled_flows = self.scale * flows
470
+ gain = sum(max(flow, 0) for flow in scaled_flows)
471
+ loss = sum(min(flow, 0) for flow in scaled_flows)
472
+ if prior is not None:
473
+ if prior < 0:
474
+ raise ValueError("The index of the prior diagram is negative")
475
+ if min(connect) < 0:
476
+ raise ValueError(
477
+ "At least one of the connection indices is negative")
478
+ if prior >= len(self.diagrams):
479
+ raise ValueError(
480
+ f"The index of the prior diagram is {prior}, but there "
481
+ f"are only {len(self.diagrams)} other diagrams")
482
+ if connect[0] >= len(self.diagrams[prior].flows):
483
+ raise ValueError(
484
+ "The connection index to the source diagram is {}, but "
485
+ "that diagram has only {} flows".format(
486
+ connect[0], len(self.diagrams[prior].flows)))
487
+ if connect[1] >= n:
488
+ raise ValueError(
489
+ f"The connection index to this diagram is {connect[1]}, "
490
+ f"but this diagram has only {n} flows")
491
+ if self.diagrams[prior].angles[connect[0]] is None:
492
+ raise ValueError(
493
+ f"The connection cannot be made, which may occur if the "
494
+ f"magnitude of flow {connect[0]} of diagram {prior} is "
495
+ f"less than the specified tolerance")
496
+ flow_error = (self.diagrams[prior].flows[connect[0]] +
497
+ flows[connect[1]])
498
+ if abs(flow_error) >= self.tolerance:
499
+ raise ValueError(
500
+ f"The scaled sum of the connected flows is {flow_error}, "
501
+ f"which is not within the tolerance ({self.tolerance})")
502
+
503
+ # Determine if the flows are inputs.
504
+ are_inputs = [None] * n
505
+ for i, flow in enumerate(flows):
506
+ if flow >= self.tolerance:
507
+ are_inputs[i] = True
508
+ elif flow <= -self.tolerance:
509
+ are_inputs[i] = False
510
+ else:
511
+ _log.info(
512
+ "The magnitude of flow %d (%f) is below the tolerance "
513
+ "(%f).\nIt will not be shown, and it cannot be used in a "
514
+ "connection.", i, flow, self.tolerance)
515
+
516
+ # Determine the angles of the arrows (before rotation).
517
+ angles = [None] * n
518
+ for i, (orient, is_input) in enumerate(zip(orientations, are_inputs)):
519
+ if orient == 1:
520
+ if is_input:
521
+ angles[i] = DOWN
522
+ elif is_input is False:
523
+ # Be specific since is_input can be None.
524
+ angles[i] = UP
525
+ elif orient == 0:
526
+ if is_input is not None:
527
+ angles[i] = RIGHT
528
+ else:
529
+ if orient != -1:
530
+ raise ValueError(
531
+ f"The value of orientations[{i}] is {orient}, "
532
+ f"but it must be -1, 0, or 1")
533
+ if is_input:
534
+ angles[i] = UP
535
+ elif is_input is False:
536
+ angles[i] = DOWN
537
+
538
+ # Justify the lengths of the paths.
539
+ if np.iterable(pathlengths):
540
+ if len(pathlengths) != n:
541
+ raise ValueError(
542
+ f"The lengths of 'flows' ({n}) and 'pathlengths' "
543
+ f"({len(pathlengths)}) are incompatible")
544
+ else: # Make pathlengths into a list.
545
+ urlength = pathlengths
546
+ ullength = pathlengths
547
+ lrlength = pathlengths
548
+ lllength = pathlengths
549
+ d = dict(RIGHT=pathlengths)
550
+ pathlengths = [d.get(angle, 0) for angle in angles]
551
+ # Determine the lengths of the top-side arrows
552
+ # from the middle outwards.
553
+ for i, (angle, is_input, flow) in enumerate(zip(angles, are_inputs,
554
+ scaled_flows)):
555
+ if angle == DOWN and is_input:
556
+ pathlengths[i] = ullength
557
+ ullength += flow
558
+ elif angle == UP and is_input is False:
559
+ pathlengths[i] = urlength
560
+ urlength -= flow # Flow is negative for outputs.
561
+ # Determine the lengths of the bottom-side arrows
562
+ # from the middle outwards.
563
+ for i, (angle, is_input, flow) in enumerate(reversed(list(zip(
564
+ angles, are_inputs, scaled_flows)))):
565
+ if angle == UP and is_input:
566
+ pathlengths[n - i - 1] = lllength
567
+ lllength += flow
568
+ elif angle == DOWN and is_input is False:
569
+ pathlengths[n - i - 1] = lrlength
570
+ lrlength -= flow
571
+ # Determine the lengths of the left-side arrows
572
+ # from the bottom upwards.
573
+ has_left_input = False
574
+ for i, (angle, is_input, spec) in enumerate(reversed(list(zip(
575
+ angles, are_inputs, zip(scaled_flows, pathlengths))))):
576
+ if angle == RIGHT:
577
+ if is_input:
578
+ if has_left_input:
579
+ pathlengths[n - i - 1] = 0
580
+ else:
581
+ has_left_input = True
582
+ # Determine the lengths of the right-side arrows
583
+ # from the top downwards.
584
+ has_right_output = False
585
+ for i, (angle, is_input, spec) in enumerate(zip(
586
+ angles, are_inputs, list(zip(scaled_flows, pathlengths)))):
587
+ if angle == RIGHT:
588
+ if is_input is False:
589
+ if has_right_output:
590
+ pathlengths[i] = 0
591
+ else:
592
+ has_right_output = True
593
+
594
+ # Begin the subpaths, and smooth the transition if the sum of the flows
595
+ # is nonzero.
596
+ urpath = [(Path.MOVETO, [(self.gap - trunklength / 2.0), # Upper right
597
+ gain / 2.0]),
598
+ (Path.LINETO, [(self.gap - trunklength / 2.0) / 2.0,
599
+ gain / 2.0]),
600
+ (Path.CURVE4, [(self.gap - trunklength / 2.0) / 8.0,
601
+ gain / 2.0]),
602
+ (Path.CURVE4, [(trunklength / 2.0 - self.gap) / 8.0,
603
+ -loss / 2.0]),
604
+ (Path.LINETO, [(trunklength / 2.0 - self.gap) / 2.0,
605
+ -loss / 2.0]),
606
+ (Path.LINETO, [(trunklength / 2.0 - self.gap),
607
+ -loss / 2.0])]
608
+ llpath = [(Path.LINETO, [(trunklength / 2.0 - self.gap), # Lower left
609
+ loss / 2.0]),
610
+ (Path.LINETO, [(trunklength / 2.0 - self.gap) / 2.0,
611
+ loss / 2.0]),
612
+ (Path.CURVE4, [(trunklength / 2.0 - self.gap) / 8.0,
613
+ loss / 2.0]),
614
+ (Path.CURVE4, [(self.gap - trunklength / 2.0) / 8.0,
615
+ -gain / 2.0]),
616
+ (Path.LINETO, [(self.gap - trunklength / 2.0) / 2.0,
617
+ -gain / 2.0]),
618
+ (Path.LINETO, [(self.gap - trunklength / 2.0),
619
+ -gain / 2.0])]
620
+ lrpath = [(Path.LINETO, [(trunklength / 2.0 - self.gap), # Lower right
621
+ loss / 2.0])]
622
+ ulpath = [(Path.LINETO, [self.gap - trunklength / 2.0, # Upper left
623
+ gain / 2.0])]
624
+
625
+ # Add the subpaths and assign the locations of the tips and labels.
626
+ tips = np.zeros((n, 2))
627
+ label_locations = np.zeros((n, 2))
628
+ # Add the top-side inputs and outputs from the middle outwards.
629
+ for i, (angle, is_input, spec) in enumerate(zip(
630
+ angles, are_inputs, list(zip(scaled_flows, pathlengths)))):
631
+ if angle == DOWN and is_input:
632
+ tips[i, :], label_locations[i, :] = self._add_input(
633
+ ulpath, angle, *spec)
634
+ elif angle == UP and is_input is False:
635
+ tips[i, :], label_locations[i, :] = self._add_output(
636
+ urpath, angle, *spec)
637
+ # Add the bottom-side inputs and outputs from the middle outwards.
638
+ for i, (angle, is_input, spec) in enumerate(reversed(list(zip(
639
+ angles, are_inputs, list(zip(scaled_flows, pathlengths)))))):
640
+ if angle == UP and is_input:
641
+ tip, label_location = self._add_input(llpath, angle, *spec)
642
+ tips[n - i - 1, :] = tip
643
+ label_locations[n - i - 1, :] = label_location
644
+ elif angle == DOWN and is_input is False:
645
+ tip, label_location = self._add_output(lrpath, angle, *spec)
646
+ tips[n - i - 1, :] = tip
647
+ label_locations[n - i - 1, :] = label_location
648
+ # Add the left-side inputs from the bottom upwards.
649
+ has_left_input = False
650
+ for i, (angle, is_input, spec) in enumerate(reversed(list(zip(
651
+ angles, are_inputs, list(zip(scaled_flows, pathlengths)))))):
652
+ if angle == RIGHT and is_input:
653
+ if not has_left_input:
654
+ # Make sure the lower path extends
655
+ # at least as far as the upper one.
656
+ if llpath[-1][1][0] > ulpath[-1][1][0]:
657
+ llpath.append((Path.LINETO, [ulpath[-1][1][0],
658
+ llpath[-1][1][1]]))
659
+ has_left_input = True
660
+ tip, label_location = self._add_input(llpath, angle, *spec)
661
+ tips[n - i - 1, :] = tip
662
+ label_locations[n - i - 1, :] = label_location
663
+ # Add the right-side outputs from the top downwards.
664
+ has_right_output = False
665
+ for i, (angle, is_input, spec) in enumerate(zip(
666
+ angles, are_inputs, list(zip(scaled_flows, pathlengths)))):
667
+ if angle == RIGHT and is_input is False:
668
+ if not has_right_output:
669
+ # Make sure the upper path extends
670
+ # at least as far as the lower one.
671
+ if urpath[-1][1][0] < lrpath[-1][1][0]:
672
+ urpath.append((Path.LINETO, [lrpath[-1][1][0],
673
+ urpath[-1][1][1]]))
674
+ has_right_output = True
675
+ tips[i, :], label_locations[i, :] = self._add_output(
676
+ urpath, angle, *spec)
677
+ # Trim any hanging vertices.
678
+ if not has_left_input:
679
+ ulpath.pop()
680
+ llpath.pop()
681
+ if not has_right_output:
682
+ lrpath.pop()
683
+ urpath.pop()
684
+
685
+ # Concatenate the subpaths in the correct order (clockwise from top).
686
+ path = (urpath + self._revert(lrpath) + llpath + self._revert(ulpath) +
687
+ [(Path.CLOSEPOLY, urpath[0][1])])
688
+
689
+ # Create a patch with the Sankey outline.
690
+ codes, vertices = zip(*path)
691
+ vertices = np.array(vertices)
692
+
693
+ def _get_angle(a, r):
694
+ if a is None:
695
+ return None
696
+ else:
697
+ return a + r
698
+
699
+ if prior is None:
700
+ if rotation != 0: # By default, none of this is needed.
701
+ angles = [_get_angle(angle, rotation) for angle in angles]
702
+ rotate = Affine2D().rotate_deg(rotation * 90).transform_affine
703
+ tips = rotate(tips)
704
+ label_locations = rotate(label_locations)
705
+ vertices = rotate(vertices)
706
+ text = self.ax.text(0, 0, s=patchlabel, ha='center', va='center')
707
+ else:
708
+ rotation = (self.diagrams[prior].angles[connect[0]] -
709
+ angles[connect[1]])
710
+ angles = [_get_angle(angle, rotation) for angle in angles]
711
+ rotate = Affine2D().rotate_deg(rotation * 90).transform_affine
712
+ tips = rotate(tips)
713
+ offset = self.diagrams[prior].tips[connect[0]] - tips[connect[1]]
714
+ translate = Affine2D().translate(*offset).transform_affine
715
+ tips = translate(tips)
716
+ label_locations = translate(rotate(label_locations))
717
+ vertices = translate(rotate(vertices))
718
+ kwds = dict(s=patchlabel, ha='center', va='center')
719
+ text = self.ax.text(*offset, **kwds)
720
+ if mpl.rcParams['_internal.classic_mode']:
721
+ fc = kwargs.pop('fc', kwargs.pop('facecolor', '#bfd1d4'))
722
+ lw = kwargs.pop('lw', kwargs.pop('linewidth', 0.5))
723
+ else:
724
+ fc = kwargs.pop('fc', kwargs.pop('facecolor', None))
725
+ lw = kwargs.pop('lw', kwargs.pop('linewidth', None))
726
+ if fc is None:
727
+ fc = self.ax._get_patches_for_fill.get_next_color()
728
+ patch = PathPatch(Path(vertices, codes), fc=fc, lw=lw, **kwargs)
729
+ self.ax.add_patch(patch)
730
+
731
+ # Add the path labels.
732
+ texts = []
733
+ for number, angle, label, location in zip(flows, angles, labels,
734
+ label_locations):
735
+ if label is None or angle is None:
736
+ label = ''
737
+ elif self.unit is not None:
738
+ if isinstance(self.format, str):
739
+ quantity = self.format % abs(number) + self.unit
740
+ elif callable(self.format):
741
+ quantity = self.format(number)
742
+ else:
743
+ raise TypeError(
744
+ 'format must be callable or a format string')
745
+ if label != '':
746
+ label += "\n"
747
+ label += quantity
748
+ texts.append(self.ax.text(x=location[0], y=location[1],
749
+ s=label,
750
+ ha='center', va='center'))
751
+ # Text objects are placed even they are empty (as long as the magnitude
752
+ # of the corresponding flow is larger than the tolerance) in case the
753
+ # user wants to provide labels later.
754
+
755
+ # Expand the size of the diagram if necessary.
756
+ self.extent = (min(np.min(vertices[:, 0]),
757
+ np.min(label_locations[:, 0]),
758
+ self.extent[0]),
759
+ max(np.max(vertices[:, 0]),
760
+ np.max(label_locations[:, 0]),
761
+ self.extent[1]),
762
+ min(np.min(vertices[:, 1]),
763
+ np.min(label_locations[:, 1]),
764
+ self.extent[2]),
765
+ max(np.max(vertices[:, 1]),
766
+ np.max(label_locations[:, 1]),
767
+ self.extent[3]))
768
+ # Include both vertices _and_ label locations in the extents; there are
769
+ # where either could determine the margins (e.g., arrow shoulders).
770
+
771
+ # Add this diagram as a subdiagram.
772
+ self.diagrams.append(
773
+ SimpleNamespace(patch=patch, flows=flows, angles=angles, tips=tips,
774
+ text=text, texts=texts))
775
+
776
+ # Allow a daisy-chained call structure (see docstring for the class).
777
+ return self
778
+
779
+ def finish(self):
780
+ """
781
+ Adjust the Axes and return a list of information about the Sankey
782
+ subdiagram(s).
783
+
784
+ Returns a list of subdiagrams with the following fields:
785
+
786
+ ======== =============================================================
787
+ Field Description
788
+ ======== =============================================================
789
+ *patch* Sankey outline (a `~matplotlib.patches.PathPatch`).
790
+ *flows* Flow values (positive for input, negative for output).
791
+ *angles* List of angles of the arrows [deg/90].
792
+ For example, if the diagram has not been rotated,
793
+ an input to the top side has an angle of 3 (DOWN),
794
+ and an output from the top side has an angle of 1 (UP).
795
+ If a flow has been skipped (because its magnitude is less
796
+ than *tolerance*), then its angle will be *None*.
797
+ *tips* (N, 2)-array of the (x, y) positions of the tips (or "dips")
798
+ of the flow paths.
799
+ If the magnitude of a flow is less the *tolerance* of this
800
+ `Sankey` instance, the flow is skipped and its tip will be at
801
+ the center of the diagram.
802
+ *text* `.Text` instance for the diagram label.
803
+ *texts* List of `.Text` instances for the flow labels.
804
+ ======== =============================================================
805
+
806
+ See Also
807
+ --------
808
+ Sankey.add
809
+ """
810
+ self.ax.axis([self.extent[0] - self.margin,
811
+ self.extent[1] + self.margin,
812
+ self.extent[2] - self.margin,
813
+ self.extent[3] + self.margin])
814
+ self.ax.set_aspect('equal', adjustable='datalim')
815
+ return self.diagrams