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,1236 @@
1
+ # Vendored from matplotlib 3.11 (see licenses/LICENSE_MATPLOTLIB), adapted for matplotlib_rs.
2
+ """
3
+ Support for plotting vector fields.
4
+
5
+ Presently this contains Quiver and Barb. Quiver plots an arrow in the
6
+ direction of the vector, with the size of the arrow related to the
7
+ magnitude of the vector.
8
+
9
+ Barbs are like quiver in that they point along a vector, but
10
+ the magnitude of the vector is given schematically by the presence of barbs
11
+ or flags on the barb.
12
+
13
+ This will also become a home for things such as standard
14
+ deviation ellipses, which can and will be derived very easily from
15
+ the Quiver code.
16
+ """
17
+
18
+ import math
19
+
20
+ import numpy as np
21
+ from numpy import ma
22
+
23
+ from matplotlib_rs import _api, cbook, _docstring
24
+ import matplotlib_rs.artist as martist
25
+ import matplotlib_rs.collections as mcollections
26
+ from matplotlib_rs.patches import CirclePolygon
27
+ import matplotlib_rs.text as mtext
28
+ import matplotlib_rs.transforms as transforms
29
+
30
+
31
+ _quiver_doc = r"""
32
+ Plot a 2D field of arrows.
33
+
34
+ Call signature::
35
+
36
+ quiver([X, Y], U, V, [C], /, **kwargs)
37
+
38
+ *X*, *Y* define the arrow locations, *U*, *V* define the arrow directions, and
39
+ *C* optionally sets the color. The arguments *X*, *Y*, *U*, *V*, *C* are
40
+ positional-only.
41
+
42
+ **Arrow length**
43
+
44
+ The default settings auto-scales the length of the arrows to a reasonable size.
45
+ To change this behavior see the *scale* and *scale_units* parameters.
46
+
47
+ **Arrow shape**
48
+
49
+ The arrow shape is determined by *width*, *headwidth*, *headlength* and
50
+ *headaxislength*. See the notes below.
51
+
52
+ **Arrow styling**
53
+
54
+ Each arrow is internally represented by a filled polygon with a default edge
55
+ linewidth of 0. As a result, an arrow is rather a filled area, not a line with
56
+ a head, and `.PolyCollection` properties like *linewidth*, *edgecolor*,
57
+ *facecolor*, etc. act accordingly.
58
+
59
+
60
+ Parameters
61
+ ----------
62
+ X, Y : 1D or 2D array-like, optional
63
+ The x and y coordinates of the arrow locations.
64
+
65
+ If not given, they will be generated as a uniform integer meshgrid based
66
+ on the dimensions of *U* and *V*.
67
+
68
+ If *X* and *Y* are 1D but *U*, *V* are 2D, *X*, *Y* are expanded to 2D
69
+ using ``X, Y = np.meshgrid(X, Y)``. In this case ``len(X)`` and ``len(Y)``
70
+ must match the column and row dimensions of *U* and *V*.
71
+
72
+ U, V : 1D or 2D array-like
73
+ The x and y direction components of the arrow vectors. The interpretation
74
+ of these components (in data or in screen space) depends on *angles*.
75
+
76
+ *U* and *V* must have the same number of elements, matching the number of
77
+ arrow locations in *X*, *Y*. *U* and *V* may be masked. Locations masked
78
+ in any of *U*, *V*, and *C* will not be drawn.
79
+
80
+ C : 1D or 2D array-like, optional
81
+ Numeric data that defines the arrow colors by colormapping via *norm* and
82
+ *cmap*.
83
+
84
+ This does not support explicit colors. If you want to set colors directly,
85
+ use *color* instead. The size of *C* must match the number of arrow
86
+ locations.
87
+
88
+ angles : {'uv', 'xy'} or array-like, default: 'uv'
89
+ Method for determining the angle of the arrows.
90
+
91
+ - 'uv': Arrow directions are based on
92
+ :ref:`display coordinates <coordinate-systems>`; i.e. a 45° angle will
93
+ always show up as diagonal on the screen, irrespective of figure or Axes
94
+ aspect ratio or Axes data ranges. This is useful when the arrows represent
95
+ a quantity whose direction is not tied to the x and y data coordinates.
96
+
97
+ If *U* == *V* the orientation of the arrow on the plot is 45 degrees
98
+ counter-clockwise from the horizontal axis (positive to the right).
99
+
100
+ - 'xy': Arrow direction in data coordinates, i.e. the arrows point from
101
+ (x, y) to (x+u, y+v). This is ideal for vector fields or gradient plots
102
+ where the arrows should directly represent movements or gradients in the
103
+ x and y directions.
104
+
105
+ - Arbitrary angles may be specified explicitly as an array of values
106
+ in degrees, counter-clockwise from the horizontal axis.
107
+
108
+ In this case *U*, *V* is only used to determine the length of the
109
+ arrows.
110
+
111
+ For example, ``angles=[30, 60, 90]`` will orient the arrows at 30, 60, and 90
112
+ degrees respectively, regardless of the *U* and *V* components.
113
+
114
+ Note: inverting a data axis will correspondingly invert the
115
+ arrows only with ``angles='xy'``.
116
+
117
+ pivot : {'tail', 'middle', 'tip'}, default: 'tail'
118
+ The part of the arrow that is anchored to the *X*, *Y* grid. The arrow
119
+ rotates about this point.
120
+
121
+ .. admonition:: Discouraged
122
+
123
+ 'mid' is a synonym for 'middle', which is retained for backwards
124
+ compatibility. New code should use 'middle'.
125
+
126
+ scale : float, optional
127
+ Scales the length of the arrow inversely.
128
+
129
+ Number of data values represented by one unit of arrow length on the plot.
130
+ For example, if the data represents velocity in meters per second (m/s), the
131
+ scale parameter determines how many meters per second correspond to one unit of
132
+ arrow length relative to the width of the plot.
133
+ Smaller scale parameter makes the arrow longer.
134
+
135
+ By default, an autoscaling algorithm is used to scale the arrow length to a
136
+ reasonable size, which is based on the average vector length and the number of
137
+ vectors.
138
+
139
+ The arrow length unit is given by the *scale_units* parameter.
140
+
141
+ scale_units : {'width', 'height', 'dots', 'inches', 'x', 'y', 'xy'}, default: 'width'
142
+ The physical image unit, which is used for rendering the scaled arrow data U, V.
143
+
144
+ The rendered arrow length is given by:
145
+
146
+ - length in x direction = :math:`\frac{u}{\mathrm{scale}}\,\mathrm{scale\_unit}`
147
+ - length in y direction = :math:`\frac{v}{\mathrm{scale}}\,\mathrm{scale\_unit}`
148
+ For example, ``(u, v) = (0.5, 0)`` with ``scale=10, scale_units="width"`` results
149
+ in a horizontal arrow with a length of *0.5 / 10 * "width"*, i.e. 0.05 times the
150
+ Axes width.
151
+
152
+ Supported values are:
153
+
154
+ - 'width' or 'height': The arrow length is scaled relative to the width or height
155
+ of the Axes.
156
+ For example, ``scale_units='width', scale=1.0``, will result in an arrow length
157
+ of width of the Axes.
158
+
159
+ - 'dots': The arrow length of the arrows is in measured in display dots (pixels).
160
+
161
+ - 'inches': Arrow lengths are scaled based on the DPI (dots per inch) of the figure.
162
+ This ensures that the arrows have a consistent physical size on the figure,
163
+ in inches, regardless of data values or plot scaling.
164
+ For example, ``(u, v) = (1, 0)`` with ``scale_units='inches', scale=2`` results
165
+ in a 0.5 inch-long arrow.
166
+
167
+ - 'x' or 'y': The arrow length is scaled relative to the x or y axis units.
168
+ For example, ``(u, v) = (0, 1)`` with ``scale_units='x', scale=1`` results
169
+ in a vertical arrow with the length of 1 x-axis unit.
170
+
171
+ - 'xy': Arrow length will be same as 'x' or 'y' units.
172
+ This is useful for creating vectors in the x-y plane where u and v have
173
+ the same units as x and y. To plot vectors in the x-y plane with u and v having
174
+ the same units as x and y, use ``angles='xy', scale_units='xy', scale=1``.
175
+
176
+ Note: Setting *scale_units* without setting scale does not have any effect because
177
+ the scale units only differ by a constant factor and that is rescaled through
178
+ autoscaling.
179
+
180
+ units : {'width', 'height', 'dots', 'inches', 'x', 'y', 'xy'}, default: 'width'
181
+ Affects the arrow size (except for the length). In particular, the shaft
182
+ *width* is measured in multiples of this unit.
183
+
184
+ Supported values are:
185
+
186
+ - 'width', 'height': The width or height of the Axes.
187
+ - 'dots', 'inches': Pixels or inches based on the figure dpi.
188
+ - 'x', 'y', 'xy': *X*, *Y* or :math:`\\sqrt{X^2 + Y^2}` in data units.
189
+
190
+ The following table summarizes how these values affect the visible arrow
191
+ size under zooming and figure size changes:
192
+
193
+ ================= ================= ==================
194
+ units zoom figure size change
195
+ ================= ================= ==================
196
+ 'x', 'y', 'xy' arrow size scales —
197
+ 'width', 'height' — arrow size scales
198
+ 'dots', 'inches' — —
199
+ ================= ================= ==================
200
+
201
+ width : float, optional
202
+ Shaft width in arrow units. All head parameters are relative to *width*.
203
+
204
+ The default depends on choice of *units* above, and number of vectors;
205
+ a typical starting value is about 0.005 times the width of the plot.
206
+
207
+ headwidth : float, default: 3
208
+ Head width as multiple of shaft *width*. See the notes below.
209
+
210
+ headlength : float, default: 5
211
+ Head length as multiple of shaft *width*. See the notes below.
212
+
213
+ headaxislength : float, default: 4.5
214
+ Head length at shaft intersection as multiple of shaft *width*.
215
+ See the notes below.
216
+
217
+ minshaft : float, default: 1
218
+ Length below which arrow scales, in units of head length. Do not
219
+ set this to less than 1, or small arrows will look terrible!
220
+
221
+ minlength : float, default: 1
222
+ Minimum length as a multiple of shaft width; if an arrow length
223
+ is less than this, plot a dot (hexagon) of this diameter instead.
224
+
225
+ color : :mpltype:`color` or list :mpltype:`color`, optional
226
+ Explicit color(s) for the arrows. If *C* has been set, *color* has no
227
+ effect.
228
+
229
+ This is a synonym for the `.PolyCollection` *facecolor* parameter.
230
+
231
+ Other Parameters
232
+ ----------------
233
+ data : indexable object, optional
234
+ DATA_PARAMETER_PLACEHOLDER
235
+
236
+ **kwargs : `~matplotlib.collections.PolyCollection` properties, optional
237
+ All other keyword arguments are passed on to `.PolyCollection`:
238
+
239
+ %(PolyCollection:kwdoc)s
240
+
241
+ Returns
242
+ -------
243
+ `~matplotlib.quiver.Quiver`
244
+
245
+ See Also
246
+ --------
247
+ .Axes.quiverkey : Add a key to a quiver plot.
248
+
249
+ Notes
250
+ -----
251
+
252
+ **Arrow shape**
253
+
254
+ The arrow is drawn as a polygon using the nodes as shown below. The values
255
+ *headwidth*, *headlength*, and *headaxislength* are in units of *width*.
256
+
257
+ .. image:: /_static/quiver_sizes.svg
258
+ :width: 500px
259
+
260
+ The defaults give a slightly swept-back arrow. Here are some guidelines how to
261
+ get other head shapes:
262
+
263
+ - To make the head a triangle, make *headaxislength* the same as *headlength*.
264
+ - To make the arrow more pointed, reduce *headwidth* or increase *headlength*
265
+ and *headaxislength*.
266
+ - To make the head smaller relative to the shaft, scale down all the head
267
+ parameters proportionally.
268
+ - To remove the head completely, set all *head* parameters to 0.
269
+ - To get a diamond-shaped head, make *headaxislength* larger than *headlength*.
270
+ - Warning: For *headaxislength* < (*headlength* / *headwidth*), the "headaxis"
271
+ nodes (i.e. the ones connecting the head with the shaft) will protrude out
272
+ of the head in forward direction so that the arrow head looks broken.
273
+ """ % _docstring.interpd.params
274
+
275
+ _docstring.interpd.register(quiver_doc=_quiver_doc)
276
+
277
+
278
+ class QuiverKey(martist.Artist):
279
+ """Labelled arrow for use as a quiver plot scale key."""
280
+ halign = {'N': 'center', 'S': 'center', 'E': 'left', 'W': 'right'}
281
+ valign = {'N': 'bottom', 'S': 'top', 'E': 'center', 'W': 'center'}
282
+ pivot = {'N': 'middle', 'S': 'middle', 'E': 'tip', 'W': 'tail'}
283
+
284
+ def __init__(self, Q, X, Y, U, label,
285
+ *, angle=0, coordinates='axes', color=None, labelsep=0.1,
286
+ labelpos='N', labelcolor=None, fontproperties=None,
287
+ zorder=None, **kwargs):
288
+ """
289
+ Add a key to a quiver plot.
290
+
291
+ The positioning of the key depends on *X*, *Y*, *coordinates*, and
292
+ *labelpos*. If *labelpos* is 'N' or 'S', *X*, *Y* give the position of
293
+ the middle of the key arrow. If *labelpos* is 'E', *X*, *Y* positions
294
+ the head, and if *labelpos* is 'W', *X*, *Y* positions the tail; in
295
+ either of these two cases, *X*, *Y* is somewhere in the middle of the
296
+ arrow+label key object.
297
+
298
+ Parameters
299
+ ----------
300
+ Q : `~matplotlib.quiver.Quiver`
301
+ A `.Quiver` object as returned by a call to `~.Axes.quiver()`.
302
+ X, Y : float
303
+ The location of the key.
304
+ U : float
305
+ The length of the key.
306
+ label : str
307
+ The key label (e.g., length and units of the key).
308
+ angle : float, default: 0
309
+ The angle of the key arrow, in degrees anti-clockwise from the
310
+ horizontal axis.
311
+ coordinates : {'axes', 'figure', 'data', 'inches'}, default: 'axes'
312
+ Coordinate system and units for *X*, *Y*: 'axes' and 'figure' are
313
+ normalized coordinate systems with (0, 0) in the lower left and
314
+ (1, 1) in the upper right; 'data' are the axes data coordinates
315
+ (used for the locations of the vectors in the quiver plot itself);
316
+ 'inches' is position in the figure in inches, with (0, 0) at the
317
+ lower left corner.
318
+ color : :mpltype:`color`
319
+ Overrides face and edge colors from *Q*.
320
+ labelpos : {'N', 'S', 'E', 'W'}
321
+ Position the label above, below, to the right, to the left of the
322
+ arrow, respectively.
323
+ labelsep : float, default: 0.1
324
+ Distance in inches between the arrow and the label.
325
+ labelcolor : :mpltype:`color`, default: :rc:`text.color`
326
+ Label color.
327
+ fontproperties : dict, optional
328
+ A dictionary with keyword arguments accepted by the
329
+ `~matplotlib.font_manager.FontProperties` initializer:
330
+ *family*, *style*, *variant*, *size*, *weight*.
331
+ zorder : float
332
+ The zorder of the key. The default is 0.1 above *Q*.
333
+ **kwargs
334
+ Any additional keyword arguments are used to override vector
335
+ properties taken from *Q*.
336
+ """
337
+ super().__init__()
338
+ self.Q = Q
339
+ self.X = X
340
+ self.Y = Y
341
+ self.U = U
342
+ self.angle = angle
343
+ self.coord = coordinates
344
+ self.color = color
345
+ self.label = label
346
+ self._labelsep_inches = labelsep
347
+
348
+ self.labelpos = labelpos
349
+ self._kw = kwargs # Remove when kw deprecation elapses.
350
+ self.vector = mcollections.PolyCollection(
351
+ [], **{**self.Q.polykw, **kwargs})
352
+ self.text = mtext.Text(
353
+ text=label,
354
+ horizontalalignment=self.halign[self.labelpos],
355
+ verticalalignment=self.valign[self.labelpos],
356
+ fontproperties=fontproperties or {})
357
+ if labelcolor is not None:
358
+ self.text.set_color(labelcolor)
359
+ self._dpi_at_last_init = None
360
+ self.zorder = zorder if zorder is not None else Q.zorder + 0.1
361
+
362
+ kw = _api.deprecated("3.11")( # Also remove self._kw when deprecation elapses.
363
+ property(lambda self: self._kw))
364
+ fontproperties = _api.deprecated(
365
+ "3.11", alternative="quiverkey.text.get_fontproperties()")(
366
+ property(lambda self: self.text.get_fontproperties()))
367
+ labelcolor = _api.deprecated(
368
+ "3.11", alternative="quiverkey.text.get_color()")(
369
+ property(lambda self: self.text.get_color()))
370
+ verts = _api.deprecated(
371
+ "3.11", alternative="[p.vertices for p in quiverkey.vector.get_paths()]")(
372
+ property(lambda self: [p.vertices for p in self.vector.get_paths()]))
373
+
374
+ @property
375
+ def labelsep(self):
376
+ return self._labelsep_inches * self.Q.axes.get_figure(root=True).dpi
377
+
378
+ def _init(self):
379
+ if False: # self._dpi_at_last_init == self.axes.get_figure().dpi
380
+ return
381
+ if self.Q._dpi_at_last_init != self.Q.axes.get_figure(root=True).dpi:
382
+ self.Q._init()
383
+ self._set_transform()
384
+ with cbook._setattr_cm(self.Q, pivot=self.pivot[self.labelpos],
385
+ # Hack: save and restore the Umask
386
+ Umask=ma.nomask):
387
+ u = self.U * np.cos(np.radians([self.angle]))
388
+ v = self.U * np.sin(np.radians([self.angle]))
389
+ verts = self.Q._make_verts([[0., 0.]], u, v, 'uv')
390
+ self.vector.set(
391
+ verts=verts,
392
+ offsets=[(self.X, self.Y)],
393
+ offset_transform=self.get_transform(),
394
+ transform=self.Q.get_transform(),
395
+ figure=self.get_figure(),
396
+ )
397
+ if self.color is not None:
398
+ self.vector.set_color(self.color)
399
+ self._dpi_at_last_init = self.Q.axes.get_figure(root=True).dpi
400
+
401
+ def _text_shift(self):
402
+ return {
403
+ "N": (0, +self.labelsep),
404
+ "S": (0, -self.labelsep),
405
+ "E": (+self.labelsep, 0),
406
+ "W": (-self.labelsep, 0),
407
+ }[self.labelpos]
408
+
409
+ @martist.allow_rasterization
410
+ def draw(self, renderer):
411
+ self._init()
412
+ self.vector.draw(renderer)
413
+ pos = self.get_transform().transform((self.X, self.Y))
414
+ self.text.set_position(pos + self._text_shift())
415
+ self.text.draw(renderer)
416
+ self.stale = False
417
+
418
+ def _set_transform(self):
419
+ fig = self.Q.axes.get_figure(root=False)
420
+ self.set_transform(_api.getitem_checked({
421
+ "data": self.Q.axes.transData,
422
+ "axes": self.Q.axes.transAxes,
423
+ "figure": fig.transFigure,
424
+ "inches": fig.dpi_scale_trans,
425
+ }, coordinates=self.coord))
426
+
427
+ def set_figure(self, fig):
428
+ super().set_figure(fig)
429
+ self.text.set_figure(fig)
430
+
431
+ def contains(self, mouseevent):
432
+ if self._different_canvas(mouseevent):
433
+ return False, {}
434
+ # Maybe the dictionary should allow one to
435
+ # distinguish between a text hit and a vector hit.
436
+ if (self.text.contains(mouseevent)[0] or
437
+ self.vector.contains(mouseevent)[0]):
438
+ return True, {}
439
+ return False, {}
440
+
441
+
442
+ def _parse_args(*args, caller_name='function'):
443
+ """
444
+ Helper function to parse positional parameters for colored vector plots.
445
+
446
+ This is currently used for Quiver and Barbs.
447
+
448
+ Parameters
449
+ ----------
450
+ *args : list
451
+ list of 2-5 arguments. Depending on their number they are parsed to::
452
+
453
+ U, V
454
+ U, V, C
455
+ X, Y, U, V
456
+ X, Y, U, V, C
457
+
458
+ caller_name : str
459
+ Name of the calling method (used in error messages).
460
+ """
461
+ X = Y = C = None
462
+
463
+ nargs = len(args)
464
+ if nargs == 2:
465
+ # The use of atleast_1d allows for handling scalar arguments while also
466
+ # keeping masked arrays
467
+ U, V = np.atleast_1d(*args)
468
+ elif nargs == 3:
469
+ U, V, C = np.atleast_1d(*args)
470
+ elif nargs == 4:
471
+ X, Y, U, V = np.atleast_1d(*args)
472
+ elif nargs == 5:
473
+ X, Y, U, V, C = np.atleast_1d(*args)
474
+ else:
475
+ raise _api.nargs_error(caller_name, takes="from 2 to 5", given=nargs)
476
+
477
+ nr, nc = (1, U.shape[0]) if U.ndim == 1 else U.shape
478
+
479
+ if X is not None:
480
+ X = X.ravel()
481
+ Y = Y.ravel()
482
+ if len(X) == nc and len(Y) == nr:
483
+ X, Y = (a.ravel() for a in np.meshgrid(X, Y))
484
+ elif len(X) != len(Y):
485
+ raise ValueError('X and Y must be the same size, but '
486
+ f'X.size is {X.size} and Y.size is {Y.size}.')
487
+ else:
488
+ indexgrid = np.meshgrid(np.arange(nc), np.arange(nr))
489
+ X, Y = (np.ravel(a) for a in indexgrid)
490
+ # Size validation for U, V, C is left to the set_UVC method.
491
+ return X, Y, U, V, C
492
+
493
+
494
+ def _check_consistent_shapes(*arrays):
495
+ all_shapes = {a.shape for a in arrays}
496
+ if len(all_shapes) != 1:
497
+ raise ValueError('The shapes of the passed in arrays do not match')
498
+
499
+
500
+ class Quiver(mcollections.PolyCollection):
501
+ """
502
+ Specialized PolyCollection for arrows.
503
+
504
+ Use set_UVC to change the size, orientation, and color of the
505
+ arrows; their locations can be set using set_offsets().
506
+
507
+ Much of the work in this class is done in the draw()
508
+ method so that as much information as possible is available
509
+ about the plot. In subsequent draw() calls, recalculation
510
+ is limited to things that might have changed, so there
511
+ should be no performance penalty from putting the calculations
512
+ in the draw() method.
513
+ """
514
+
515
+ _PIVOT_VALS = ('tail', 'middle', 'tip')
516
+
517
+ @_docstring.Substitution(_quiver_doc)
518
+ def __init__(self, ax, *args,
519
+ scale=None, headwidth=3, headlength=5, headaxislength=4.5,
520
+ minshaft=1, minlength=1, units='width', scale_units=None,
521
+ angles='uv', width=None, color='k', pivot='tail', **kwargs):
522
+ """
523
+ The constructor takes one required argument, an Axes
524
+ instance, followed by the args and kwargs described
525
+ by the following pyplot interface documentation:
526
+ %s
527
+ """
528
+ self._axes = ax # The attr actually set by the Artist.axes property.
529
+ X, Y, U, V, C = _parse_args(*args, caller_name='quiver')
530
+ self.X = X
531
+ self.Y = Y
532
+ self.XY = np.column_stack((X, Y))
533
+ self.N = len(X)
534
+ self.scale = scale
535
+ self.headwidth = headwidth
536
+ self.headlength = float(headlength)
537
+ self.headaxislength = headaxislength
538
+ self.minshaft = minshaft
539
+ self.minlength = minlength
540
+ self.units = units
541
+ self.scale_units = scale_units
542
+ self.angles = angles
543
+ self.width = width
544
+
545
+ if pivot.lower() == 'mid':
546
+ pivot = 'middle'
547
+ self.pivot = pivot.lower()
548
+ _api.check_in_list(self._PIVOT_VALS, pivot=self.pivot)
549
+
550
+ self.transform = kwargs.pop('transform', ax.transData)
551
+ kwargs.setdefault('facecolors', color)
552
+ kwargs.setdefault('linewidths', (0,))
553
+ super().__init__([], offsets=self.XY, offset_transform=self.transform,
554
+ closed=False, **kwargs)
555
+ self.polykw = kwargs
556
+ self.set_UVC(U, V, C)
557
+ self._dpi_at_last_init = None
558
+
559
+ def _init(self):
560
+ """
561
+ Initialization delayed until first draw;
562
+ allow time for axes setup.
563
+ """
564
+ # It seems that there are not enough event notifications
565
+ # available to have this work on an as-needed basis at present.
566
+ if True: # self._dpi_at_last_init != self.axes.figure.dpi
567
+ trans = self._set_transform()
568
+ self.span = trans.inverted().transform_bbox(self.axes.bbox).width
569
+ if self.width is None:
570
+ sn = np.clip(math.sqrt(self.N), 8, 25)
571
+ self.width = 0.06 * self.span / sn
572
+
573
+ # _make_verts sets self.scale if not already specified
574
+ if (self._dpi_at_last_init != self.axes.get_figure(root=True).dpi
575
+ and self.scale is None):
576
+ self._make_verts(self.XY, self.U, self.V, self.angles)
577
+
578
+ self._dpi_at_last_init = self.axes.get_figure(root=True).dpi
579
+
580
+ def get_datalim(self, transData):
581
+ trans = self.get_transform()
582
+ offset_trf = self.get_offset_transform()
583
+ full_transform = (trans - transData) + (offset_trf - transData)
584
+ XY = full_transform.transform(self.XY)
585
+ bbox = transforms.Bbox.null()
586
+ bbox.update_from_data_xy(XY, ignore=True)
587
+ return bbox
588
+
589
+ @martist.allow_rasterization
590
+ def draw(self, renderer):
591
+ self._init()
592
+ verts = self._make_verts(self.XY, self.U, self.V, self.angles)
593
+ self.set_verts(verts, closed=False)
594
+ super().draw(renderer)
595
+ self.stale = False
596
+
597
+ def set_UVC(self, U, V, C=None):
598
+ # We need to ensure we have a copy, not a reference
599
+ # to an array that might change before draw().
600
+ U = ma.masked_invalid(U, copy=True).ravel()
601
+ V = ma.masked_invalid(V, copy=True).ravel()
602
+ if C is not None:
603
+ C = ma.masked_invalid(C, copy=True).ravel()
604
+ for name, var in zip(('U', 'V', 'C'), (U, V, C)):
605
+ if not (var is None or var.size == self.N or var.size == 1):
606
+ raise ValueError(f'Argument {name} has a size {var.size}'
607
+ f' which does not match {self.N},'
608
+ ' the number of arrow positions')
609
+
610
+ mask = ma.mask_or(U.mask, V.mask, copy=False, shrink=True)
611
+ if C is not None:
612
+ mask = ma.mask_or(mask, C.mask, copy=False, shrink=True)
613
+ if mask is ma.nomask:
614
+ C = C.filled()
615
+ else:
616
+ C = ma.array(C, mask=mask, copy=False)
617
+ self.U = U.filled(1)
618
+ self.V = V.filled(1)
619
+ self.Umask = mask
620
+ if C is not None:
621
+ self.set_array(C)
622
+ self.stale = True
623
+
624
+ def _dots_per_unit(self, units):
625
+ """Return a scale factor for converting from units to pixels."""
626
+ bb = self.axes.bbox
627
+ vl = self.axes.viewLim
628
+ return _api.getitem_checked({
629
+ 'x': bb.width / vl.width,
630
+ 'y': bb.height / vl.height,
631
+ 'xy': np.hypot(*bb.size) / np.hypot(*vl.size),
632
+ 'width': bb.width,
633
+ 'height': bb.height,
634
+ 'dots': 1.,
635
+ 'inches': self.axes.get_figure(root=True).dpi,
636
+ }, units=units)
637
+
638
+ def _set_transform(self):
639
+ """
640
+ Set the PolyCollection transform to go
641
+ from arrow width units to pixels.
642
+ """
643
+ dx = self._dots_per_unit(self.units)
644
+ self._trans_scale = dx # pixels per arrow width unit
645
+ trans = transforms.Affine2D().scale(dx)
646
+ self.set_transform(trans)
647
+ return trans
648
+
649
+ # Calculate angles and lengths for segment between (x, y), (x+u, y+v)
650
+ def _angles_lengths(self, XY, U, V, eps=1):
651
+ xy = self.axes.transData.transform(XY)
652
+ uv = np.column_stack((U, V))
653
+ xyp = self.axes.transData.transform(XY + eps * uv)
654
+ dxy = xyp - xy
655
+ angles = np.arctan2(dxy[:, 1], dxy[:, 0])
656
+ lengths = np.hypot(*dxy.T) / eps
657
+ return angles, lengths
658
+
659
+ # XY is stacked [X, Y].
660
+ # See quiver() doc for meaning of X, Y, U, V, angles.
661
+ def _make_verts(self, XY, U, V, angles):
662
+ uv = (U + V * 1j)
663
+ str_angles = angles if isinstance(angles, str) else ''
664
+ if str_angles == 'xy' and self.scale_units == 'xy':
665
+ # Here eps is 1 so that if we get U, V by diffing
666
+ # the X, Y arrays, the vectors will connect the
667
+ # points, regardless of the axis scaling (including log).
668
+ angles, lengths = self._angles_lengths(XY, U, V, eps=1)
669
+ elif str_angles == 'xy' or self.scale_units == 'xy':
670
+ # Calculate eps based on the extents of the plot
671
+ # so that we don't end up with roundoff error from
672
+ # adding a small number to a large.
673
+ eps = np.abs(self.axes.dataLim.extents).max() * 0.001
674
+ angles, lengths = self._angles_lengths(XY, U, V, eps=eps)
675
+
676
+ if str_angles and self.scale_units == 'xy':
677
+ a = lengths
678
+ else:
679
+ a = np.abs(uv)
680
+
681
+ if self.scale is None:
682
+ sn = max(10, math.sqrt(self.N))
683
+ if self.Umask is not ma.nomask:
684
+ amean = a[~self.Umask].mean()
685
+ else:
686
+ amean = a.mean()
687
+ # crude auto-scaling
688
+ # scale is typical arrow length as a multiple of the arrow width
689
+ scale = 1.8 * amean * sn / self.span
690
+
691
+ if self.scale_units is None:
692
+ if self.scale is None:
693
+ self.scale = scale
694
+ widthu_per_lenu = 1.0
695
+ else:
696
+ if self.scale_units == 'xy':
697
+ dx = 1
698
+ else:
699
+ dx = self._dots_per_unit(self.scale_units)
700
+ widthu_per_lenu = dx / self._trans_scale
701
+ if self.scale is None:
702
+ self.scale = scale * widthu_per_lenu
703
+ length = a * (widthu_per_lenu / (self.scale * self.width))
704
+ X, Y = self._h_arrows(length)
705
+ if str_angles == 'xy':
706
+ theta = angles
707
+ elif str_angles == 'uv':
708
+ theta = np.angle(uv)
709
+ else:
710
+ theta = ma.masked_invalid(np.deg2rad(angles)).filled(0)
711
+ theta = theta.reshape((-1, 1)) # for broadcasting
712
+ xy = (X + Y * 1j) * np.exp(1j * theta) * self.width
713
+ XY = np.stack((xy.real, xy.imag), axis=2)
714
+ if self.Umask is not ma.nomask:
715
+ XY = ma.array(XY)
716
+ XY[self.Umask] = ma.masked
717
+ # This might be handled more efficiently with nans, given
718
+ # that nans will end up in the paths anyway.
719
+
720
+ return XY
721
+
722
+ def _h_arrows(self, length):
723
+ """Length is in arrow width units."""
724
+ # It might be possible to streamline the code
725
+ # and speed it up a bit by using complex (x, y)
726
+ # instead of separate arrays; but any gain would be slight.
727
+ minsh = self.minshaft * self.headlength
728
+ N = len(length)
729
+ length = length.reshape(N, 1)
730
+ # This number is chosen based on when pixel values overflow in Agg
731
+ # causing rendering errors
732
+ # length = np.minimum(length, 2 ** 16)
733
+ np.clip(length, 0, 2 ** 16, out=length)
734
+ # x, y: normal horizontal arrow
735
+ x = np.array([0, -self.headaxislength,
736
+ -self.headlength, 0],
737
+ np.float64)
738
+ x = x + np.array([0, 1, 1, 1]) * length
739
+ y = 0.5 * np.array([1, 1, self.headwidth, 0], np.float64)
740
+ y = np.repeat(y[np.newaxis, :], N, axis=0)
741
+ # x0, y0: arrow without shaft, for short vectors
742
+ x0 = np.array([0, minsh - self.headaxislength,
743
+ minsh - self.headlength, minsh], np.float64)
744
+ y0 = 0.5 * np.array([1, 1, self.headwidth, 0], np.float64)
745
+ ii = [0, 1, 2, 3, 2, 1, 0, 0]
746
+ X = x[:, ii]
747
+ Y = y[:, ii]
748
+ Y[:, 3:-1] *= -1
749
+ X0 = x0[ii]
750
+ Y0 = y0[ii]
751
+ Y0[3:-1] *= -1
752
+ shrink = length / minsh if minsh != 0. else 0.
753
+ X0 = shrink * X0[np.newaxis, :]
754
+ Y0 = shrink * Y0[np.newaxis, :]
755
+ short = np.repeat(length < minsh, 8, axis=1)
756
+ # Now select X0, Y0 if short, otherwise X, Y
757
+ np.copyto(X, X0, where=short)
758
+ np.copyto(Y, Y0, where=short)
759
+ if self.pivot == 'middle':
760
+ X -= 0.5 * X[:, 3, np.newaxis]
761
+ elif self.pivot == 'tip':
762
+ # numpy bug? using -= does not work here unless we multiply by a
763
+ # float first, as with 'mid'.
764
+ X = X - X[:, 3, np.newaxis]
765
+ elif self.pivot != 'tail':
766
+ _api.check_in_list(["middle", "tip", "tail"], pivot=self.pivot)
767
+
768
+ tooshort = length < self.minlength
769
+ if tooshort.any():
770
+ # Use a heptagonal dot:
771
+ th = np.arange(0, 8, 1, np.float64) * (np.pi / 3.0)
772
+ x1 = np.cos(th) * self.minlength * 0.5
773
+ y1 = np.sin(th) * self.minlength * 0.5
774
+ X1 = np.repeat(x1[np.newaxis, :], N, axis=0)
775
+ Y1 = np.repeat(y1[np.newaxis, :], N, axis=0)
776
+ tooshort = np.repeat(tooshort, 8, 1)
777
+ np.copyto(X, X1, where=tooshort)
778
+ np.copyto(Y, Y1, where=tooshort)
779
+ # Mask handling is deferred to the caller, _make_verts.
780
+ return X, Y
781
+
782
+
783
+ _barbs_doc = r"""
784
+ Plot a 2D field of wind barbs.
785
+
786
+ Call signature::
787
+
788
+ barbs([X, Y], U, V, [C], /, **kwargs)
789
+
790
+ Where *X*, *Y* define the barb locations, *U*, *V* define the barb
791
+ directions, and *C* optionally sets the color.
792
+
793
+ The arguments *X*, *Y*, *U*, *V*, *C* are positional-only and may be
794
+ 1D or 2D. *U*, *V*, *C* may be masked arrays, but masked *X*, *Y*
795
+ are not supported at present.
796
+
797
+ Barbs are traditionally used in meteorology as a way to plot the speed
798
+ and direction of wind observations, but can technically be used to
799
+ plot any two dimensional vector quantity. As opposed to arrows, which
800
+ give vector magnitude by the length of the arrow, the barbs give more
801
+ quantitative information about the vector magnitude by putting slanted
802
+ lines or a triangle for various increments in magnitude, as show
803
+ schematically below::
804
+
805
+ : /\ \
806
+ : / \ \
807
+ : / \ \ \
808
+ : / \ \ \
809
+ : ------------------------------
810
+
811
+ The largest increment is given by a triangle (or "flag"). After those
812
+ come full lines (barbs). The smallest increment is a half line. There
813
+ is only, of course, ever at most 1 half line. If the magnitude is
814
+ small and only needs a single half-line and no full lines or
815
+ triangles, the half-line is offset from the end of the barb so that it
816
+ can be easily distinguished from barbs with a single full line. The
817
+ magnitude for the barb shown above would nominally be 65, using the
818
+ standard increments of 50, 10, and 5.
819
+
820
+ See also https://en.wikipedia.org/wiki/Wind_barb.
821
+
822
+ Parameters
823
+ ----------
824
+ X, Y : 1D or 2D array-like, optional
825
+ The x and y coordinates of the barb locations. See *pivot* for how the
826
+ barbs are drawn to the x, y positions.
827
+
828
+ If not given, they will be generated as a uniform integer meshgrid based
829
+ on the dimensions of *U* and *V*.
830
+
831
+ If *X* and *Y* are 1D but *U*, *V* are 2D, *X*, *Y* are expanded to 2D
832
+ using ``X, Y = np.meshgrid(X, Y)``. In this case ``len(X)`` and ``len(Y)``
833
+ must match the column and row dimensions of *U* and *V*.
834
+
835
+ U, V : 1D or 2D array-like
836
+ The x and y components of the barb shaft.
837
+
838
+ C : 1D or 2D array-like, optional
839
+ Numeric data that defines the barb colors by colormapping via *norm* and
840
+ *cmap*.
841
+
842
+ This does not support explicit colors. If you want to set colors directly,
843
+ use *barbcolor* instead.
844
+
845
+ length : float, default: 7
846
+ Length of the barb in points; the other parts of the barb
847
+ are scaled against this.
848
+
849
+ pivot : {'tip', 'middle'} or float, default: 'tip'
850
+ The part of the arrow that is anchored to the *X*, *Y* grid. The barb
851
+ rotates about this point. This can also be a number, which shifts the
852
+ start of the barb that many points away from grid point.
853
+
854
+ barbcolor : :mpltype:`color` or color sequence
855
+ The color of all parts of the barb except for the flags. This parameter
856
+ is analogous to the *edgecolor* parameter for polygons, which can be used
857
+ instead. However this parameter will override facecolor.
858
+
859
+ flagcolor : :mpltype:`color` or color sequence
860
+ The color of any flags on the barb. This parameter is analogous to the
861
+ *facecolor* parameter for polygons, which can be used instead. However,
862
+ this parameter will override facecolor. If this is not set (and *C* has
863
+ not either) then *flagcolor* will be set to match *barbcolor* so that the
864
+ barb has a uniform color. If *C* has been set, *flagcolor* has no effect.
865
+
866
+ sizes : dict, optional
867
+ A dictionary of coefficients specifying the ratio of a given
868
+ feature to the length of the barb. Only those values one wishes to
869
+ override need to be included. These features include:
870
+
871
+ - 'spacing' - space between features (flags, full/half barbs)
872
+ - 'height' - height (distance from shaft to top) of a flag or full barb
873
+ - 'width' - width of a flag, twice the width of a full barb
874
+ - 'emptybarb' - radius of the circle used for low magnitudes
875
+
876
+ fill_empty : bool, default: False
877
+ Whether the empty barbs (circles) that are drawn should be filled with
878
+ the flag color. If they are not filled, the center is transparent.
879
+
880
+ rounding : bool, default: True
881
+ Whether the vector magnitude should be rounded when allocating barb
882
+ components. If True, the magnitude is rounded to the nearest multiple
883
+ of the half-barb increment. If False, the magnitude is simply truncated
884
+ to the next lowest multiple.
885
+
886
+ barb_increments : dict, optional
887
+ A dictionary of increments specifying values to associate with
888
+ different parts of the barb. Only those values one wishes to
889
+ override need to be included.
890
+
891
+ - 'half' - half barbs (Default is 5)
892
+ - 'full' - full barbs (Default is 10)
893
+ - 'flag' - flags (default is 50)
894
+
895
+ flip_barb : bool or array-like of bool, default: False
896
+ Whether the lines and flags should point opposite to normal.
897
+ Normal behavior is for the barbs and lines to point right (comes from wind
898
+ barbs having these features point towards low pressure in the Northern
899
+ Hemisphere).
900
+
901
+ A single value is applied to all barbs. Individual barbs can be flipped by
902
+ passing a bool array of the same size as *U* and *V*.
903
+
904
+ Returns
905
+ -------
906
+ barbs : `~matplotlib.quiver.Barbs`
907
+
908
+ Other Parameters
909
+ ----------------
910
+ data : indexable object, optional
911
+ DATA_PARAMETER_PLACEHOLDER
912
+
913
+ **kwargs
914
+ The barbs can further be customized using `.PolyCollection` keyword
915
+ arguments:
916
+
917
+ %(PolyCollection:kwdoc)s
918
+ """ % _docstring.interpd.params
919
+
920
+ _docstring.interpd.register(barbs_doc=_barbs_doc)
921
+
922
+
923
+ class Barbs(mcollections.PolyCollection):
924
+ """
925
+ Specialized PolyCollection for barbs.
926
+
927
+ The only API method is :meth:`set_UVC`, which can be used to
928
+ change the size, orientation, and color of the arrows. Locations
929
+ are changed using the :meth:`set_offsets` collection method.
930
+ Possibly this method will be useful in animations.
931
+
932
+ There is one internal function :meth:`!_find_tails` which finds
933
+ exactly what should be put on the barb given the vector magnitude.
934
+ From there :meth:`!_make_barbs` is used to find the vertices of the
935
+ polygon to represent the barb based on this information.
936
+ """
937
+
938
+ # This may be an abuse of polygons here to render what is essentially maybe
939
+ # 1 triangle and a series of lines. It works fine as far as I can tell
940
+ # however.
941
+
942
+ @_docstring.interpd
943
+ def __init__(self, ax, *args,
944
+ pivot='tip', length=7, barbcolor=None, flagcolor=None,
945
+ sizes=None, fill_empty=False, barb_increments=None,
946
+ rounding=True, flip_barb=False, **kwargs):
947
+ """
948
+ The constructor takes one required argument, an Axes
949
+ instance, followed by the args and kwargs described
950
+ by the following pyplot interface documentation:
951
+ %(barbs_doc)s
952
+ """
953
+ self.sizes = sizes or dict()
954
+ self.fill_empty = fill_empty
955
+ self.barb_increments = barb_increments or dict()
956
+ self.rounding = rounding
957
+ self.flip = np.atleast_1d(flip_barb)
958
+ transform = kwargs.pop('transform', ax.transData)
959
+ self._pivot = pivot
960
+ self._length = length
961
+
962
+ # Flagcolor and barbcolor provide convenience parameters for
963
+ # setting the facecolor and edgecolor, respectively, of the barb
964
+ # polygon. We also work here to make the flag the same color as the
965
+ # rest of the barb by default
966
+
967
+ if None in (barbcolor, flagcolor):
968
+ kwargs['edgecolors'] = 'face'
969
+ if flagcolor:
970
+ kwargs['facecolors'] = flagcolor
971
+ elif barbcolor:
972
+ kwargs['facecolors'] = barbcolor
973
+ else:
974
+ # Set to facecolor passed in or default to black
975
+ kwargs.setdefault('facecolors', 'k')
976
+ else:
977
+ kwargs['edgecolors'] = barbcolor
978
+ kwargs['facecolors'] = flagcolor
979
+
980
+ # Explicitly set a line width if we're not given one, otherwise
981
+ # polygons are not outlined and we get no barbs
982
+ if 'linewidth' not in kwargs and 'lw' not in kwargs:
983
+ kwargs['linewidth'] = 1
984
+
985
+ # Parse out the data arrays from the various configurations supported
986
+ x, y, u, v, c = _parse_args(*args, caller_name='barbs')
987
+ self.x = x
988
+ self.y = y
989
+ xy = np.column_stack((x, y))
990
+
991
+ # Make a collection
992
+ barb_size = self._length ** 2 / 4 # Empirically determined
993
+ super().__init__(
994
+ [], (barb_size,), offsets=xy, offset_transform=transform, **kwargs)
995
+ self.set_transform(transforms.IdentityTransform())
996
+
997
+ self.set_UVC(u, v, c)
998
+
999
+ def _find_tails(self, mag, rounding=True, half=5, full=10, flag=50):
1000
+ """
1001
+ Find how many of each of the tail pieces is necessary.
1002
+
1003
+ Parameters
1004
+ ----------
1005
+ mag : `~numpy.ndarray`
1006
+ Vector magnitudes; must be non-negative (and an actual ndarray).
1007
+ rounding : bool, default: True
1008
+ Whether to round or to truncate to the nearest half-barb.
1009
+ half, full, flag : float, defaults: 5, 10, 50
1010
+ Increments for a half-barb, a barb, and a flag.
1011
+
1012
+ Returns
1013
+ -------
1014
+ n_flags, n_barbs : int array
1015
+ For each entry in *mag*, the number of flags and barbs.
1016
+ half_flag : bool array
1017
+ For each entry in *mag*, whether a half-barb is needed.
1018
+ empty_flag : bool array
1019
+ For each entry in *mag*, whether nothing is drawn.
1020
+ """
1021
+ # If rounding, round to the nearest multiple of half, the smallest
1022
+ # increment
1023
+ if rounding:
1024
+ mag = half * np.around(mag / half)
1025
+ n_flags, mag = divmod(mag, flag)
1026
+ n_barb, mag = divmod(mag, full)
1027
+ half_flag = mag >= half
1028
+ empty_flag = ~(half_flag | (n_flags > 0) | (n_barb > 0))
1029
+ return n_flags.astype(int), n_barb.astype(int), half_flag, empty_flag
1030
+
1031
+ def _make_barbs(self, u, v, nflags, nbarbs, half_barb, empty_flag, length,
1032
+ pivot, sizes, fill_empty, flip):
1033
+ """
1034
+ Create the wind barbs.
1035
+
1036
+ Parameters
1037
+ ----------
1038
+ u, v
1039
+ Components of the vector in the x and y directions, respectively.
1040
+
1041
+ nflags, nbarbs, half_barb, empty_flag
1042
+ Respectively, the number of flags, number of barbs, flag for
1043
+ half a barb, and flag for empty barb, ostensibly obtained from
1044
+ :meth:`_find_tails`.
1045
+
1046
+ length
1047
+ The length of the barb staff in points.
1048
+
1049
+ pivot : {"tip", "middle"} or number
1050
+ The point on the barb around which the entire barb should be
1051
+ rotated. If a number, the start of the barb is shifted by that
1052
+ many points from the origin.
1053
+
1054
+ sizes : dict
1055
+ Coefficients specifying the ratio of a given feature to the length
1056
+ of the barb. These features include:
1057
+
1058
+ - *spacing*: space between features (flags, full/half barbs).
1059
+ - *height*: distance from shaft of top of a flag or full barb.
1060
+ - *width*: width of a flag, twice the width of a full barb.
1061
+ - *emptybarb*: radius of the circle used for low magnitudes.
1062
+
1063
+ fill_empty : bool
1064
+ Whether the circle representing an empty barb should be filled or
1065
+ not (this changes the drawing of the polygon).
1066
+
1067
+ flip : list of bool
1068
+ Whether the features should be flipped to the other side of the
1069
+ barb (useful for winds in the southern hemisphere).
1070
+
1071
+ Returns
1072
+ -------
1073
+ list of arrays of vertices
1074
+ Polygon vertices for each of the wind barbs. These polygons have
1075
+ been rotated to properly align with the vector direction.
1076
+ """
1077
+
1078
+ # These control the spacing and size of barb elements relative to the
1079
+ # length of the shaft
1080
+ spacing = length * sizes.get('spacing', 0.125)
1081
+ full_height = length * sizes.get('height', 0.4)
1082
+ full_width = length * sizes.get('width', 0.25)
1083
+ empty_rad = length * sizes.get('emptybarb', 0.15)
1084
+
1085
+ # Controls y point where to pivot the barb.
1086
+ pivot_points = dict(tip=0.0, middle=-length / 2.)
1087
+
1088
+ endx = 0.0
1089
+ try:
1090
+ endy = float(pivot)
1091
+ except ValueError:
1092
+ endy = pivot_points[pivot.lower()]
1093
+
1094
+ # Get the appropriate angle for the vector components. The offset is
1095
+ # due to the way the barb is initially drawn, going down the y-axis.
1096
+ # This makes sense in a meteorological mode of thinking since there 0
1097
+ # degrees corresponds to north (the y-axis traditionally)
1098
+ angles = -(ma.arctan2(v, u) + np.pi / 2)
1099
+
1100
+ # Used for low magnitude. We just get the vertices, so if we make it
1101
+ # out here, it can be reused. The center set here should put the
1102
+ # center of the circle at the location(offset), rather than at the
1103
+ # same point as the barb pivot; this seems more sensible.
1104
+ circ = CirclePolygon((0, 0), radius=empty_rad).get_verts()
1105
+ if fill_empty:
1106
+ empty_barb = circ
1107
+ else:
1108
+ # If we don't want the empty one filled, we make a degenerate
1109
+ # polygon that wraps back over itself
1110
+ empty_barb = np.concatenate((circ, circ[::-1]))
1111
+
1112
+ barb_list = []
1113
+ for index, angle in np.ndenumerate(angles):
1114
+ # If the vector magnitude is too weak to draw anything, plot an
1115
+ # empty circle instead
1116
+ if empty_flag[index]:
1117
+ # We can skip the transform since the circle has no preferred
1118
+ # orientation
1119
+ barb_list.append(empty_barb)
1120
+ continue
1121
+
1122
+ poly_verts = [(endx, endy)]
1123
+ offset = length
1124
+
1125
+ # Handle if this barb should be flipped
1126
+ barb_height = -full_height if flip[index] else full_height
1127
+
1128
+ # Add vertices for each flag
1129
+ for i in range(nflags[index]):
1130
+ # The spacing that works for the barbs is a little to much for
1131
+ # the flags, but this only occurs when we have more than 1
1132
+ # flag.
1133
+ if offset != length:
1134
+ offset += spacing / 2.
1135
+ poly_verts.extend(
1136
+ [[endx, endy + offset],
1137
+ [endx + barb_height, endy - full_width / 2 + offset],
1138
+ [endx, endy - full_width + offset]])
1139
+
1140
+ offset -= full_width + spacing
1141
+
1142
+ # Add vertices for each barb. These really are lines, but works
1143
+ # great adding 3 vertices that basically pull the polygon out and
1144
+ # back down the line
1145
+ for i in range(nbarbs[index]):
1146
+ poly_verts.extend(
1147
+ [(endx, endy + offset),
1148
+ (endx + barb_height, endy + offset + full_width / 2),
1149
+ (endx, endy + offset)])
1150
+
1151
+ offset -= spacing
1152
+
1153
+ # Add the vertices for half a barb, if needed
1154
+ if half_barb[index]:
1155
+ # If the half barb is the first on the staff, traditionally it
1156
+ # is offset from the end to make it easy to distinguish from a
1157
+ # barb with a full one
1158
+ if offset == length:
1159
+ poly_verts.append((endx, endy + offset))
1160
+ offset -= 1.5 * spacing
1161
+ poly_verts.extend(
1162
+ [(endx, endy + offset),
1163
+ (endx + barb_height / 2, endy + offset + full_width / 4),
1164
+ (endx, endy + offset)])
1165
+
1166
+ # Rotate the barb according the angle. Making the barb first and
1167
+ # then rotating it made the math for drawing the barb really easy.
1168
+ # Also, the transform framework makes doing the rotation simple.
1169
+ poly_verts = transforms.Affine2D().rotate(-angle).transform(
1170
+ poly_verts)
1171
+ barb_list.append(poly_verts)
1172
+
1173
+ return barb_list
1174
+
1175
+ def set_UVC(self, U, V, C=None):
1176
+ # We need to ensure we have a copy, not a reference to an array that
1177
+ # might change before draw().
1178
+ self.u = ma.masked_invalid(U, copy=True).ravel()
1179
+ self.v = ma.masked_invalid(V, copy=True).ravel()
1180
+
1181
+ # Flip needs to have the same number of entries as everything else.
1182
+ # Use broadcast_to to avoid a bloated array of identical values.
1183
+ # (can't rely on actual broadcasting)
1184
+ if len(self.flip) == 1:
1185
+ flip = np.broadcast_to(self.flip, self.u.shape)
1186
+ else:
1187
+ flip = self.flip
1188
+
1189
+ if C is not None:
1190
+ c = ma.masked_invalid(C, copy=True).ravel()
1191
+ x, y, u, v, c, flip = cbook.delete_masked_points(
1192
+ self.x.ravel(), self.y.ravel(), self.u, self.v, c,
1193
+ flip.ravel())
1194
+ _check_consistent_shapes(x, y, u, v, c, flip)
1195
+ else:
1196
+ x, y, u, v, flip = cbook.delete_masked_points(
1197
+ self.x.ravel(), self.y.ravel(), self.u, self.v, flip.ravel())
1198
+ _check_consistent_shapes(x, y, u, v, flip)
1199
+
1200
+ magnitude = np.hypot(u, v)
1201
+ flags, barbs, halves, empty = self._find_tails(
1202
+ magnitude, self.rounding, **self.barb_increments)
1203
+
1204
+ # Get the vertices for each of the barbs
1205
+
1206
+ plot_barbs = self._make_barbs(u, v, flags, barbs, halves, empty,
1207
+ self._length, self._pivot, self.sizes,
1208
+ self.fill_empty, flip)
1209
+ self.set_verts(plot_barbs)
1210
+
1211
+ # Set the color array
1212
+ if C is not None:
1213
+ self.set_array(c)
1214
+
1215
+ # Update the offsets in case the masked data changed
1216
+ xy = np.column_stack((x, y))
1217
+ self._offsets = xy
1218
+ self.stale = True
1219
+
1220
+ def set_offsets(self, xy):
1221
+ """
1222
+ Set the offsets for the barb polygons. This saves the offsets passed
1223
+ in and masks them as appropriate for the existing U/V data.
1224
+
1225
+ Parameters
1226
+ ----------
1227
+ xy : sequence of pairs of floats
1228
+ """
1229
+ self.x = xy[:, 0]
1230
+ self.y = xy[:, 1]
1231
+ x, y, u, v = cbook.delete_masked_points(
1232
+ self.x.ravel(), self.y.ravel(), self.u, self.v)
1233
+ _check_consistent_shapes(x, y, u, v)
1234
+ xy = np.column_stack((x, y))
1235
+ super().set_offsets(xy)
1236
+ self.stale = True