Title: [MNT]: sort out renderers · Issue #22744 · matplotlib/matplotlib · GitHub
Open Graph Title: [MNT]: sort out renderers · Issue #22744 · matplotlib/matplotlib
X Title: [MNT]: sort out renderers · Issue #22744 · matplotlib/matplotlib
Description: Summary Various methods require a renderer, in particular get_tightbbox and get_window_extent. We have quite a few inconsistencies here. Many implementations of get_window_extent have renderer as an optional kwarg, and fallback: fallback...
Open Graph Description: Summary Various methods require a renderer, in particular get_tightbbox and get_window_extent. We have quite a few inconsistencies here. Many implementations of get_window_extent have renderer as a...
X Description: Summary Various methods require a renderer, in particular get_tightbbox and get_window_extent. We have quite a few inconsistencies here. Many implementations of get_window_extent have renderer as a...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/22744
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[MNT]: sort out renderers","articleBody":"### Summary\n\nVarious methods require a renderer, in particular `get_tightbbox` and `get_window_extent`. We have quite a few inconsistencies here.\r\n\r\nMany implementations of `get_window_extent` have `renderer` as an optional kwarg, and fallback: fallbacks are `self.figure._cachedRenderer` (`Text`, `Legend`) and some other `get_window_extent` don't need the renderer. \r\n\r\n`get_tightbbox` always needs the renderer, but largely to pass to `get_window_extent` calls on `Text` objects. \r\n\r\n`tight_layout` and `constrained_layout` need the renderer, but that is only because they want to pass it to the `get_tightbbox`. \r\n\r\n\n\n### Proposed fix\n\n\r\nIt _seems_ that we don't need to specify the renderer most of the time in `get_window_extent`, but can safely fall back on the `_cachedRenderer` or `fig.canvas.get_renderer`, so it seems more consistent to just make this argument always optional. However, perhaps I'm missing a subtlety where the user may want to call `get_window_extent(renderer=different_renderer)`, but I have no idea what that use case is. \r\n\r\n1. make renderer a kwarg in all `get_window_extent` methods.\r\n3. improve the fallbacks in all the `get_window_extents`: I'm not sure `_cachedRenderer` is adequate, and we probably want `Figure._get_cachedRenderer` that has some fallbacks in `_cachedRenderer` is None, or fakes a draw to fill the cache. \r\n4. make renderer an optional kwarg in all `get_tightbbox` methods. \r\n\r\nThis needs comment though from folks who understand the renderer system better: @QuLogic @anntzer @tacaswell ? Thanks!","author":{"url":"https://github.com/jklymak","@type":"Person","name":"jklymak"},"datePublished":"2022-03-31T07:45:23.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":6},"url":"https://github.com/22744/matplotlib/issues/22744"}
| 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:4cb634e3-1cd6-eada-c82a-250b5c3a400e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DDF6:3CF864:15C0B8D:1CC635C:6A51C053 |
| html-safe-nonce | 68852d8cea26f0a49d9923fb401aca63b2e2b8f366237a88fb74ef446543d1ac |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEREY2OjNDRjg2NDoxNUMwQjhEOjFDQzYzNUM6NkE1MUMwNTMiLCJ2aXNpdG9yX2lkIjoiNjUxMzEwNTE4OTMyMjQ3MzU1NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 018ebc3063795284953ef9ccf3c6e04fe3a61c26230c5e94d39e03b3918c423f |
| hovercard-subject-tag | issue:1187655230 |
| 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/22744/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ff8baff5c609b73eb84fd4d8af0d8006e67d0327e97c5bec5dfa6ff6a4d28a4f/matplotlib/matplotlib/issues/22744 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ff8baff5c609b73eb84fd4d8af0d8006e67d0327e97c5bec5dfa6ff6a4d28a4f/matplotlib/matplotlib/issues/22744 |
| og:image:alt | Summary Various methods require a renderer, in particular get_tightbbox and get_window_extent. We have quite a few inconsistencies here. Many implementations of get_window_extent have renderer as a... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jklymak |
| 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