Title: [Bug]: 3.5.0 colorbar outside of its axis when saved into vectorial formats · Issue #21672 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: 3.5.0 colorbar outside of its axis when saved into vectorial formats · Issue #21672 · matplotlib/matplotlib
X Title: [Bug]: 3.5.0 colorbar outside of its axis when saved into vectorial formats · Issue #21672 · matplotlib/matplotlib
Description: Bug summary For some figure/subplot/colorbar axis aspect ratios, the colorbar is outside of its axes when saved into vectorial formats (pdf, svg). Code for reproduction import numpy as np import matplotlib.pyplot as plt x = np.linspace(0...
Open Graph Description: Bug summary For some figure/subplot/colorbar axis aspect ratios, the colorbar is outside of its axes when saved into vectorial formats (pdf, svg). Code for reproduction import numpy as np import ma...
X Description: Bug summary For some figure/subplot/colorbar axis aspect ratios, the colorbar is outside of its axes when saved into vectorial formats (pdf, svg). Code for reproduction import numpy as np import ma...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/21672
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: 3.5.0 colorbar outside of its axis when saved into vectorial formats","articleBody":"### Bug summary\n\nFor some figure/subplot/colorbar axis aspect ratios, the colorbar is outside of its axes when saved into vectorial formats (pdf, svg).\n\n### Code for reproduction\n\n```python\nimport numpy as np\r\nimport matplotlib.pyplot as plt\r\n\r\nx = np.linspace(0, 100, 100)\r\ny = np.linspace(0, 100, 100)\r\nz = x[None, :]**2 + y[:, None]**2\r\n\r\nfig, axarr = plt.subplots(1, 2, figsize=(3, 2.8789385625),\r\n constrained_layout=True, sharey=True)\r\nax = axarr[0]\r\na = ax.pcolormesh(x, y, z, snap=True)\r\nfig.colorbar(a, ax=ax, location='top')\r\n#\r\nax = axarr[1]\r\na = ax.pcolormesh(x, y, z, snap=True)\r\nfig.colorbar(a, ax=ax, location='top')\r\nplt.savefig('test_colorbar.pdf')\r\nplt.savefig('test_colorbar.svg')\r\nplt.savefig('test_colorbar.png', dpi=800)\n```\n\n\n### Actual outcome\n\n\r\n\n\n### Expected outcome\n\nThe colorbar should be within its axis, and not shifted upward.\n\n### Additional information\n\n- It does not occur when the figure is saved to non-vectorial format (i.e png, etc ..)\r\n- In this case, it does not occur for all figure aspect ratios.\r\n- It was already the case in matplotlib 3.4.3\n\n### Operating system\n\nUbuntu 20\n\n### Matplotlib Version\n\n3.5.0\n\n### Matplotlib Backend\n\nQtAgg\n\n### Python version\n\n3.8.10\n\n### Jupyter version\n\n_No response_\n\n### Installation\n\npip","author":{"url":"https://github.com/cgadal","@type":"Person","name":"cgadal"},"datePublished":"2021-11-18T16:04:21.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/21672/matplotlib/issues/21672"}
| 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:35f6e127-0a99-c4b0-c944-b0aebe4ed51b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 869A:238007:718277:97C9DC:6A518F35 |
| html-safe-nonce | 1eb687b818b90a2fe050fd0ec65df7f72211a0bbcff6fe8b7af1df517784cc7b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NjlBOjIzODAwNzo3MTgyNzc6OTdDOURDOjZBNTE4RjM1IiwidmlzaXRvcl9pZCI6IjI3MDIxNDE3MTM1NzM1ODA1OTciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 0b93f1c8ccf62c9894def8e9b03e24baf1df0fb1bcf0022292cfb539840e3d07 |
| hovercard-subject-tag | issue:1057527291 |
| 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/21672/issue_layout |
| twitter:image | https://opengraph.githubassets.com/df91776c230bd4bd39df5751f604fc1f8ce1337908cae080bfeecf30f8cb4115/matplotlib/matplotlib/issues/21672 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/df91776c230bd4bd39df5751f604fc1f8ce1337908cae080bfeecf30f8cb4115/matplotlib/matplotlib/issues/21672 |
| og:image:alt | Bug summary For some figure/subplot/colorbar axis aspect ratios, the colorbar is outside of its axes when saved into vectorial formats (pdf, svg). Code for reproduction import numpy as np import ma... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | cgadal |
| 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