-
-
Notifications
You must be signed in to change notification settings - Fork 8.1k
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: fallbacks are self.figure._cachedRenderer (Text, Legend) and some other get_window_extent don't need the renderer.
get_tightbbox always needs the renderer, but largely to pass to get_window_extent calls on Text objects.
tight_layout and constrained_layout need the renderer, but that is only because they want to pass it to the get_tightbbox.
Proposed fix
It 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.
- make renderer a kwarg in all
get_window_extentmethods. - improve the fallbacks in all the
get_window_extents: I'm not sure_cachedRendereris adequate, and we probably wantFigure._get_cachedRendererthat has some fallbacks in_cachedRendereris None, or fakes a draw to fill the cache. - make renderer an optional kwarg in all
get_tightbboxmethods.
This needs comment though from folks who understand the renderer system better: @QuLogic @anntzer @tacaswell ? Thanks!