Title: Inconsistency with behavior of extent and origin in imshow() · Issue #8693 · matplotlib/matplotlib · GitHub
Open Graph Title: Inconsistency with behavior of extent and origin in imshow() · Issue #8693 · matplotlib/matplotlib
X Title: Inconsistency with behavior of extent and origin in imshow() · Issue #8693 · matplotlib/matplotlib
Description: Following a brief discussion on Gitter, I've decided to open an issue here but I'm not 100% sure if this is a bug or intended behavior. The following script compares the usage of origin and extent when the limits are fixed to the same in...
Open Graph Description: Following a brief discussion on Gitter, I've decided to open an issue here but I'm not 100% sure if this is a bug or intended behavior. The following script compares the usage of origin and extent ...
X Description: Following a brief discussion on Gitter, I've decided to open an issue here but I'm not 100% sure if this is a bug or intended behavior. The following script compares the usage of origin and...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/8693
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Inconsistency with behavior of extent and origin in imshow()","articleBody":"Following a brief discussion on Gitter, I've decided to open an issue here but I'm not 100% sure if this is a bug or intended behavior. The following script compares the usage of origin and extent when the limits are fixed to the same intervals and same axis direction:\r\n\r\n```python\r\nimport numpy as np\r\nimport matplotlib.pyplot as plt\r\n\r\nimage = np.arange(100).reshape((10, 10))\r\n\r\nsubplot = 0\r\n\r\nfig = plt.figure(figsize=(8, 8))\r\n\r\nfor extent in [None, [1, 9, 1, 9]]:\r\n for origin in ['lower', 'upper']:\r\n subplot += 1\r\n ax = fig.add_subplot(2, 2, subplot)\r\n ax.imshow(image, interpolation='nearest', origin=origin,\r\n extent=extent)\r\n ax.set_xlim(0, 10)\r\n ax.set_ylim(0, 10)\r\n ax.set_title('extent={0} origin={1}'.format(extent, origin),\r\n fontsize=8)\r\n\r\nfig.savefig('thumbs.png')\r\n```\r\n\r\nThe output is:\r\n\r\n\r\n\r\nAs you can see, when no extent is specified, the origin keyword has no impact on the result whereas it does when the extent is specified.\r\n\r\nThere is either a bug here, or something that exists for historical reasons that deserves its own documentation section.\r\n\r\nIn any case, the documentation for ``origin`` doesn't make much sense:\r\n\r\n```\r\norigin : ['upper' | 'lower'], optional, default: None\r\n Place the [0,0] index of the array in the upper left or lower left\r\n corner of the axes. If None, default to rc `image.origin`.\r\n```\r\n\r\nthe concept of 'upper left' or 'lower left' is tricky since the axes can be made to go in either direction, so whether [0,0] is at the upper or lower corner visually depends on the direction of the axes.\r\n\r\nIt seems that when extent is not specified, origin simply means that the y limits are flipped but this can be reverted by setting ylim. When extent is present, the array is truly flipped vertically.\r\n\r\ncc @tacaswell @ngoldbaum @WeatherGod \r\n\r\n","author":{"url":"https://github.com/astrofrog","@type":"Person","name":"astrofrog"},"datePublished":"2017-05-31T20:55:27.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":9},"url":"https://github.com/8693/matplotlib/issues/8693"}
| 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:43214902-ba5c-c349-e439-2eaaeda05df7 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DFDA:36B7C0:542EA1:719AD2:6A57D1BC |
| html-safe-nonce | 5bc0b4f4df843f227994788cb8141d8bb2293232ac8d2738d296934da6f07195 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERkRBOjM2QjdDMDo1NDJFQTE6NzE5QUQyOjZBNTdEMUJDIiwidmlzaXRvcl9pZCI6IjMxMjI0Mjc2MTUyMjQ3NzkxOTYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 2ff29fffb3115cd2fc9cad3a446324a0fbcc2c86e28dd80b278e4f4b462c476e |
| hovercard-subject-tag | issue:232693300 |
| 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/8693/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ab270b731e529a7f280a517dc2952cdd66e24a382e729edb8942cfcd889a5867/matplotlib/matplotlib/issues/8693 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ab270b731e529a7f280a517dc2952cdd66e24a382e729edb8942cfcd889a5867/matplotlib/matplotlib/issues/8693 |
| og:image:alt | Following a brief discussion on Gitter, I've decided to open an issue here but I'm not 100% sure if this is a bug or intended behavior. The following script compares the usage of origin and extent ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | astrofrog |
| hostname | github.com |
| expected-hostname | github.com |
| None | 837767abbd14b05f219fd812ef2842c659968b63619e1b966dded83972ab5bca |
| 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 | 9044d0f867aa9892268d1f430238ff123e11ee91 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width