Title: FIX: don't pad axes for ticks if they aren't visible or axis off by jklymak · Pull Request #11210 · matplotlib/matplotlib · GitHub
Open Graph Title: FIX: don't pad axes for ticks if they aren't visible or axis off by jklymak · Pull Request #11210 · matplotlib/matplotlib
X Title: FIX: don't pad axes for ticks if they aren't visible or axis off by jklymak · Pull Request #11210 · matplotlib/matplotlib
Description: PR Summary Since 1.5.3 (two years ago) we added: matplotlib/lib/matplotlib/axes/_base.py Lines 580 to 589 in 1652ed1 def get_window_extent(self, *args, **kwargs): """ get the axes bounding box in display space; *args* and *kwargs* are empty """ bbox = self.bbox x_pad = self.xaxis.get_tick_padding() y_pad = self.yaxis.get_tick_padding() return mtransforms.Bbox([[bbox.x0 - x_pad, bbox.y0 - y_pad], [bbox.x1 + x_pad, bbox.y1 + y_pad]]) First, this seems like a funny place to put the padding for ticks - I'd have expected it to be in the axis bbox, not the axes bbox. But presumably someone wanted to know the extent of the axes and its ticks w/o knowing the rest of the decorators? The original issues that spurred #5683 seemed to be tight_layout not respecting outward ticks. IMHO this "fix" was wrong and the axis bboxes should include the ticks not the axes, But xaxis.get_tightbbox does not include the ticks even though it controls everything about the ticks. Second, ax.set_axis_off sets aax.axison=False, but it doesn't change the visibility of the axis, which is still True. I haven't fixed this, but it seems strange to have two flags that control the visibility of an axis. Anyways, this is an easy fix given how things are now to make the tightbbox actually behave like there are no ticks present. Closes: #11203 Probably needs a good test.... Milestoning 3.0 as this regression is very old. import numpy as np from matplotlib import pyplot as plt # axis ticks removed fig, ax = plt.subplots(figsize=(1,1)) ax.matshow(np.ones((10,10)), cmap=plt.cm.Blues_r, aspect='auto') ax.set_xticklabels([]) ax.set_yticklabels([]) ax.axis('off') fig.tight_layout() fig.savefig('test_noticks.png', dpi=300, bbox_inches='tight', pad_inches=0, facecolor='red') before after PR Checklist Has Pytest style unit tests Code is PEP 8 compliant
Open Graph Description: PR Summary Since 1.5.3 (two years ago) we added: matplotlib/lib/matplotlib/axes/_base.py Lines 580 to 589 in 1652ed1 ...
X Description: PR Summary Since 1.5.3 (two years ago) we added: matplotlib/lib/matplotlib/axes/_base.py Lines 580 to 589 in 1652ed1 ...
Opengraph URL: https://github.com/matplotlib/matplotlib/pull/11210
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:c8b073ab-e07d-a9df-235a-fcb09247d5f9 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | D29E:348621:F30478:1464183:6A54410E |
| html-safe-nonce | e0b1ed743e2298b0788e95ec4600ce4a5156ed204207720f661077cfd8689894 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMjlFOjM0ODYyMTpGMzA0Nzg6MTQ2NDE4Mzo2QTU0NDEwRSIsInZpc2l0b3JfaWQiOiI3MjU3NDg2NDE5NzMxNjkzODM4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 5fdcc3211836f3f25e10278b6831b0ca826b426a910f49c3dacf3360c20661b0 |
| hovercard-subject-tag | pull_request:186982380 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,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/matplotlib/matplotlib/pull/11210/files |
| twitter:image | https://avatars.githubusercontent.com/u/1562854?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/1562854?s=400&v=4 |
| og:image:alt | PR Summary Since 1.5.3 (two years ago) we added: matplotlib/lib/matplotlib/axes/_base.py Lines 580 to 589 in 1652ed1 ... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| turbo-cache-control | no-preview |
| diff-view | unified |
| 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 full-width |
| disable-turbo | true |
| 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