Title: Issue · GitHub
Open Graph Title: Issue · matplotlib/matplotlib
X Title: Issue · matplotlib/matplotlib
Description: matplotlib: plotting with Python. Contribute to matplotlib/matplotlib development by creating an account on GitHub.
Open Graph Description: matplotlib: plotting with Python. Contribute to matplotlib/matplotlib development by creating an account on GitHub.
X Description: matplotlib: plotting with Python. Contribute to matplotlib/matplotlib development by creating an account on GitHub.
Opengraph URL: https://github.com/matplotlib/matplotlib
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: Units behavior of `streamplot`","articleBody":"### Bug summary\n\nAs seen in #27489 `streamplot` does not allow passing unitful data as x/y\n\n### Code for reproduction\n\n```python\nfig, ax = plt.subplots()\r\n\r\nnp.random.seed(19680801)\r\nlimit_value = 30\r\n\r\ndate_array = np.array(\r\n [datetime.datetime(2023, 12, n) for n in range(1, limit_value)]\r\n , dtype=np.datetime64)\r\n#date_array_converted = mpl.dates.date2num(date_array)\r\nX, Y = np.meshgrid(date_array, date_array)\r\nU = np.random.rand(limit_value-1, limit_value-1)\r\nV = np.random.rand(limit_value-1, limit_value-1)\r\n\r\nax.streamplot(X, Y, U, V)\n```\n\n\n### Actual outcome\n\n```python\r\nTraceback (most recent call last):\r\n File \"/home/kyle/play/gh27487.py\", line 22, in \u003cmodule\u003e\r\n ax.streamplot(X, Y, U, V)\r\n File \"/home/kyle/src/scipy/matplotlib/lib/matplotlib/__init__.py\", line 1472, in inner\r\n return func(\r\n ^^^^^\r\n File \"/home/kyle/src/scipy/matplotlib/lib/matplotlib/streamplot.py\", line 91, in streamplot\r\n grid = Grid(x, y)\r\n ^^^^^^^^^^\r\n File \"/home/kyle/src/scipy/matplotlib/lib/matplotlib/streamplot.py\", line 330, in __init__\r\n if not np.allclose(x_row, x):\r\n ^^^^^^^^^^^^^^^^^^^^^\r\n File \"/home/kyle/.pyenv/versions/edge/lib/python3.11/site-packages/numpy/core/numeric.py\", line 2241, in allc\r\nlose\r\n res = all(isclose(a, b, rtol=rtol, atol=atol, equal_nan=equal_nan))\r\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n File \"/home/kyle/.pyenv/versions/edge/lib/python3.11/site-packages/numpy/core/numeric.py\", line 2345, in iscl\r\nose\r\n dt = multiarray.result_type(y, 1.)\r\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\nnumpy.exceptions.DTypePromotionError: The DType \u003cclass 'numpy._FloatAbstractDType'\u003e could not be promoted by \u003cc\r\nlass 'numpy.dtypes.DateTime64DType'\u003e. This means that no common DType exists for the given inputs. For example \r\nthey cannot be stored in a single array unless the dtype is `object`. The full list of DTypes is: (\u003cclass 'nump\r\ny.dtypes.DateTime64DType'\u003e, \u003cclass 'numpy._FloatAbstractDType'\u003e)\r\n```\n\n### Expected outcome\n\nUnits can be passed as at least X/Ya (I could see requiring them to be the _same_ units... or even saying \"this type of plot _shouldn't_ support units\", but would want to be explicit about that.\r\n\r\nI do wonder a bit about `U/V` and whether they should be specified in `delta` units or not? `quiver` can treat them as independent values or as delta values, I believe, but don't see such a distinction on stream lines.\n\n### Additional information\n\nMay be as easy as calling `_process_unit_info` on the inputs, I think.\n\n### Operating system\n\n_No response_\n\n### Matplotlib Version\n\n3.9.0.dev821+gfa6be74127 (~main at time of reporting)\n\n### Matplotlib Backend\n\n_No response_\n\n### Python version\n\n_No response_\n\n### Jupyter version\n\n_No response_\n\n### Installation\n\ngit checkout","author":{"url":"https://github.com/ksunden","@type":"Person","name":"ksunden"},"datePublished":"2023-12-12T01:12:31.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/27500/matplotlib/issues/27500"}
| route-pattern | /:user_id/:repository/issues/:id(.:format) |
| route-controller | issues |
| route-action | show |
| fetch-nonce | v2:70e78515-e112-9237-765d-294594144f31 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8846:292EED:501B4B:6A97C6:6A52D7EF |
| html-safe-nonce | a2cadad9eeec025f0818eb921a654836246ad2d89e9317821f949808bc47a206 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4ODQ2OjI5MkVFRDo1MDFCNEI6NkE5N0M2OjZBNTJEN0VGIiwidmlzaXRvcl9pZCI6IjIzODcyNTYyODUwNTE2NzI1NTkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 369c96198d6571feceb207411585633ad37408c6a13c0072478c758675f2a6f8 |
| hovercard-subject-tag | repository:1385122 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/matplotlib/matplotlib/issues/27500 |
| twitter:image | https://opengraph.githubassets.com/c30144758eec9e3324965530d5a5d5f25f1694c957399cc9975eb81431640b5e/matplotlib/matplotlib |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c30144758eec9e3324965530d5a5d5f25f1694c957399cc9975eb81431640b5e/matplotlib/matplotlib |
| og:image:alt | matplotlib: plotting with Python. Contribute to matplotlib/matplotlib development by creating an account on GitHub. |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| turbo-cache-control | no-cache |
| go-import | github.com/matplotlib/matplotlib git https://github.com/matplotlib/matplotlib.git |
| octolytics-dimension-user_id | 215947 |
| octolytics-dimension-user_login | matplotlib |
| octolytics-dimension-repository_id | 1385122 |
| octolytics-dimension-repository_nwo | matplotlib/matplotlib |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1385122 |
| octolytics-dimension-repository_network_root_nwo | matplotlib/matplotlib |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 07a982c1d40157c619b364352b704c3ce66bb332 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width