Title: Location of subplot.set_aspect(...) matters for imshow · Issue #2540 · matplotlib/matplotlib · GitHub
Open Graph Title: Location of subplot.set_aspect(...) matters for imshow · Issue #2540 · matplotlib/matplotlib
X Title: Location of subplot.set_aspect(...) matters for imshow · Issue #2540 · matplotlib/matplotlib
Description: The location of the command subplot.set_aspect('auto') - whether it is before or after the command subplot.imshow(...) - determines whether the aspect ratio is properly set. The aspect ratio is properly set only if the set_aspect command...
Open Graph Description: The location of the command subplot.set_aspect('auto') - whether it is before or after the command subplot.imshow(...) - determines whether the aspect ratio is properly set. The aspect ratio is pro...
X Description: The location of the command subplot.set_aspect('auto') - whether it is before or after the command subplot.imshow(...) - determines whether the aspect ratio is properly set. The aspect rati...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/2540
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Location of subplot.set_aspect(...) matters for imshow","articleBody":"The location of the command `subplot.set_aspect('auto')` - whether it is before or after the command `subplot.imshow(...)` - determines whether the aspect ratio is properly set. The aspect ratio is properly set only if the `set_aspect` command follows the `imshow` command. The same holds true if other values are passed to `set_aspect`, such as `set_aspect(0.05)`.\n\nThis discrepancy is most pronounced for plots with very disproportionate vertical and horizontal ranges. An example code is given below:\n\n```\nx = range(10)\ny = [10**_ for _ in range(10)]\nxmuly = [[i*j for j in y] for i in x]\n# Uncomment this and comment the set_aspect below imshow to see the bug.\n#subplot.set_aspect('auto', adjustable='box')\nsubplot.imshow(xmuly, origin='lower', cmap='jet', extent=[0,9,10**0,10**9], interpolation='catrom')\nsubplot.set_aspect('auto', adjustable='box')\n```\n\nThis code can be tested live [here](http://aleph.sagemath.org/?z=eJyNUk1vozAQvftXjNQDsEIoHHvgUK20_6CnKEUDDI6zYCN7SMm_72CSJu1Kq15gPt58vOfpvRthRJ4Gx4Npit7o2ROYcXKe4U_0VP8N1GD7l2wXbkaNWn8t-Y32jOFFa6WuHatrJs1UmJu1k4S2XIFdV1-DaVmWmVKLJD1aTWm5y9RFvH25e6uhdx5qMPaePKhlnIeI2Jtfp4g4rYjLIdpmtZeDUk_wals3jmQZ-GgCoO3gHiAIxDWGiVqGhgb3LozCUX7sJEUR0sy6UE_XVYt7QZrgzC7JAbvTHBibgaqkcUvySbbYmqVx2RycN9rYKpEx5KWuHXGqkhOx2LSwrFTtd_lzLqR36-f5kAsPJj-5Adk4KW2R5VkeJvxonf_LgI070z-8kcEwdI6CVFt5ODkFWQXejySi-EfhpJ94op9IT8ISsF-Rq3brjlK_jpKRuWgZ2269wvZWcfCDwvEilhwu2e2OIss2Xlf67dTSDZFlNygbfeR6wIubOf2MBjyTmKJRMVmdZB9VHguM\u0026lang=sage).\n\nThis problem is not present when `subplot.plot(...)` is used. The aspect ratio is always correctly set irrespective of whether the `set_aspect` command comes before or after the `plot` command.\n\nCorresponding Sage ticket: http://trac.sagemath.org/15315\n","author":{"url":"https://github.com/ppurka","@type":"Person","name":"ppurka"},"datePublished":"2013-10-23T18:22:34.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/2540/matplotlib/issues/2540"}
| 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:600c909a-7918-e714-0550-190896e1fa31 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CD5E:2CE7AA:4FCD4BD:6F4A5FA:6A54FF28 |
| html-safe-nonce | d461caf2bb9757f1f5980a149b48e176c7b9ecb5b15b21f8f13177e5130f0f6d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRDVFOjJDRTdBQTo0RkNENEJEOjZGNEE1RkE6NkE1NEZGMjgiLCJ2aXNpdG9yX2lkIjoiMjExNjMzNjc5NjA2MTQ2NjQwOCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 8b5379846272d1b353d5a63f722200314cba95a4c39b30628bd64d32908f5a25 |
| hovercard-subject-tag | issue:21473513 |
| 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/2540/issue_layout |
| twitter:image | https://opengraph.githubassets.com/177acf1e4fe9c1af925878246d2caa9e1355bb8458b63fa0d0dab65cfbb2eb79/matplotlib/matplotlib/issues/2540 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/177acf1e4fe9c1af925878246d2caa9e1355bb8458b63fa0d0dab65cfbb2eb79/matplotlib/matplotlib/issues/2540 |
| og:image:alt | The location of the command subplot.set_aspect('auto') - whether it is before or after the command subplot.imshow(...) - determines whether the aspect ratio is properly set. The aspect ratio is pro... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ppurka |
| hostname | github.com |
| expected-hostname | github.com |
| None | eae2aab99907699a22d2c8449aa683ca74454fca87211b98f7c7b722086b2839 |
| 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 | 6a35ab858be185cd86d12b93a43bccf34e8d8536 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width