Title: [Bug]: fig.subplots_adjust and ax.set_yticklabels together can produce unexpected results · Issue #26398 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: fig.subplots_adjust and ax.set_yticklabels together can produce unexpected results · Issue #26398 · matplotlib/matplotlib
X Title: [Bug]: fig.subplots_adjust and ax.set_yticklabels together can produce unexpected results · Issue #26398 · matplotlib/matplotlib
Description: Bug summary Setting y ticks and labels directly on an axis and then adjusting the top of the subplot of the figure can have unexpected consequences. Depending on where those ticks and labels were originally, and how the top ratio is set,...
Open Graph Description: Bug summary Setting y ticks and labels directly on an axis and then adjusting the top of the subplot of the figure can have unexpected consequences. Depending on where those ticks and labels were o...
X Description: Bug summary Setting y ticks and labels directly on an axis and then adjusting the top of the subplot of the figure can have unexpected consequences. Depending on where those ticks and labels were o...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/26398
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: fig.subplots_adjust and ax.set_yticklabels together can produce unexpected results","articleBody":"### Bug summary\r\n\r\nSetting y ticks and labels directly on an **axis** and then adjusting the top of the subplot of the **figure** can have unexpected consequences. Depending on where those ticks and labels were originally, and how the `top` ratio is set, labels will not go until the top of the y-axis, instead all the values appear with much less vertical spacing on the bottom part of the axis.\r\n\r\n### Code for reproduction\r\n\r\n```python\r\nimport matplotlib.pyplot as plt\r\nfrom mpl_toolkits.axisartist import SubplotHost\r\n\r\nfig = plt.figure(figsize=(25, 3)) # Originally setting a large enough height fixed our problem, but in this example it did not help\r\n\r\nax = SubplotHost(fig, 111)\r\nfig.add_subplot(ax)\r\n# ax = fig.add_subplot(111) # using this produces the same outcome\r\n\r\ndata = [33.4, 33.5, 33.6]\r\n\r\nax.plot(data, data)\r\n\r\nticks = [32.8, 33., 33.2, 33.4, 33.6, 33.8]\r\n\r\n# Anomaly because labels won't match with ticks anymore if the next line is commented out\r\n# ax.set_yticks(ticks)\r\nax.set_yticklabels(map(str, ticks))\r\n\r\n# In this little example the bug is only triggered when the anomaly above holds\r\nfig.subplots_adjust(top=0.96)\r\n\r\nplt.show(dpi=300)\r\n```\r\n\r\n\r\n### Actual outcome\r\n\r\n\r\n\r\n### Expected outcome\r\n\r\n\r\n\r\n\r\n### Additional information\r\n\r\nI suspect it depends on where those ticks and labels were originally, because we were also able to produce this bug where there was no mismatch required between labels and ticks.\r\nIt might also depend on the number of the top ratio being set.\r\nAs far as I know, adjusting other ratios (left, right, bottom, wspace, hspace) did not have an effect on this.\r\n\r\n### Operating system\r\n\r\nUbuntu 22.04\r\n\r\n### Matplotlib Version\r\n\r\n3.5.1\r\n\r\n### Matplotlib Backend\r\n\r\nagg\r\n\r\n### Python version\r\n\r\n3.9.12\r\n\r\n### Jupyter version\r\n\r\n_No response_\r\n\r\n### Installation\r\n\r\npip","author":{"url":"https://github.com/foldvaridominic","@type":"Person","name":"foldvaridominic"},"datePublished":"2023-07-27T08:27:08.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":10},"url":"https://github.com/26398/matplotlib/issues/26398"}
| 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:1b1f9bef-7e42-8f02-e22f-73c4782c6a2e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E4D0:108FC:10C06C:161CB6:6A52EC4F |
| html-safe-nonce | 4614dc71a6c46582e5199cbeee936b6633526ccad5ce4d8b47285c88b34fa765 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNEQwOjEwOEZDOjEwQzA2QzoxNjFDQjY6NkE1MkVDNEYiLCJ2aXNpdG9yX2lkIjoiNjc4NTg4Mjc1NDE3OTU5MTI0NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | e170c27beea79cdfda7c65e9e15b72f1940478d7d1c8fb3b8de7da55bf6a4c62 |
| hovercard-subject-tag | issue:1823872528 |
| 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/26398/issue_layout |
| twitter:image | https://opengraph.githubassets.com/bca7af893cffcd83ea48059ea4ab20d17a0c2cf5a7c2004a3d5099de1d68f242/matplotlib/matplotlib/issues/26398 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/bca7af893cffcd83ea48059ea4ab20d17a0c2cf5a7c2004a3d5099de1d68f242/matplotlib/matplotlib/issues/26398 |
| og:image:alt | Bug summary Setting y ticks and labels directly on an axis and then adjusting the top of the subplot of the figure can have unexpected consequences. Depending on where those ticks and labels were o... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | foldvaridominic |
| 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 | 07a982c1d40157c619b364352b704c3ce66bb332 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width