Title: Allow use of unitful data in images · Issue #19476 · matplotlib/matplotlib · GitHub
Open Graph Title: Allow use of unitful data in images · Issue #19476 · matplotlib/matplotlib
X Title: Allow use of unitful data in images · Issue #19476 · matplotlib/matplotlib
Description: Problem Often the data stored in images can have physical values associated with them. It would therefore be good if there was support for using the unit machinery to allow images to have units. Proposed Solution Here's a short example t...
Open Graph Description: Problem Often the data stored in images can have physical values associated with them. It would therefore be good if there was support for using the unit machinery to allow images to have units. Pr...
X Description: Problem Often the data stored in images can have physical values associated with them. It would therefore be good if there was support for using the unit machinery to allow images to have units. Pr...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/19476
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Allow use of unitful data in images","articleBody":"\u003c!--\r\nWelcome! Thanks for thinking of a way to improve Matplotlib.\r\n\r\n\r\nBefore creating a new feature request please search the issues for relevant feature requests.\r\n--\u003e\r\n\r\n### Problem\r\nOften the data stored in images can have physical values associated with them. It would therefore be good if there was support for using the unit machinery to allow images to have units.\r\n\r\n### Proposed Solution\r\nHere's a short example that should work fine using units, but which currently fails. The use of datetime is a bit contrived, but I chose it to avoid a third party package. For a more realistic real-world example see https://github.com/astropy/astropy/issues/11306.\r\n```python\r\nfrom datetime import datetime\r\nimport matplotlib.colors as mcolor\r\nimport matplotlib.pyplot as plt\r\n\r\ndata = [[datetime.now(), datetime.now()],\r\n [datetime.now(), datetime.now()]]\r\n\r\nfig, ax = plt.subplots()\r\nim = ax.imshow(data, norm=mcolor.LogNorm())\r\nfig.colorbar(im)\r\n\r\nplt.show()\r\n```\r\nThis fails in\r\n```python\r\n File \"/Users/dstansby/github/matplotlib/lib/matplotlib/axes/_axes.py\", line 5586, in imshow\r\n im.set_data(X)\r\n File \"/Users/dstansby/github/matplotlib/lib/matplotlib/image.py\", line 700, in set_data\r\n raise TypeError(\"Image data of dtype {} cannot be converted to \"\r\nTypeError: Image data of dtype object cannot be converted to float\r\n```","author":{"url":"https://github.com/dstansby","@type":"Person","name":"dstansby"},"datePublished":"2021-02-08T09:38:13.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":5},"url":"https://github.com/19476/matplotlib/issues/19476"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:4ef86f47-e7b0-fd18-a6a8-103f0f715fc4 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D686:D8572:AF182:F302B:6A52583D |
| html-safe-nonce | 5478d2a5887f6555ef2ede64b6eed0ad7dfdb8a6bc4b995c6ced5c2b64b05cc9 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENjg2OkQ4NTcyOkFGMTgyOkYzMDJCOjZBNTI1ODNEIiwidmlzaXRvcl9pZCI6IjcyMjA0OTk0NTQxNjM1NzI3OTciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | e7c2ef24be388219c1aed8e24cf6dbb34037fe83668290943fce39fee848a372 |
| hovercard-subject-tag | issue:803381216 |
| 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/_view_fragments/issues/show/matplotlib/matplotlib/19476/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e6eca5dac9a8438f6b771eb0a10f69709f0179d8046e90b59c3e4c96a1021437/matplotlib/matplotlib/issues/19476 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e6eca5dac9a8438f6b771eb0a10f69709f0179d8046e90b59c3e4c96a1021437/matplotlib/matplotlib/issues/19476 |
| og:image:alt | Problem Often the data stored in images can have physical values associated with them. It would therefore be good if there was support for using the unit machinery to allow images to have units. Pr... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dstansby |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| turbo-cache-control | no-preview |
| 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 | 7aed05249554b889eb33d002851a973eebcc7e91 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width