You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
FigureCanvasAgg.renderer and FigureCanvasAgg.get_renderer have subtly different semantics #13099
def get_renderer(self, cleared=False):
l, b, w, h = self.figure.bbox.bounds
key = w, h, self.figure.dpi
reuse_renderer = (hasattr(self, "renderer")
and getattr(self, "_lastKey", None) == key)
if not reuse_renderer:
self.renderer = RendererAgg(w, h, self.figure.dpi)
self._lastKey = key
elif cleared:
self.renderer.clear()
return self.renderer
i.e. (ignoring the cleared kwarg) if the figure bbox or dpi has changed, generate a new renderer.
Although this won't matter in most cases, it will in the figure saving routines as they manipulate the dpi, or (in GUI backends) when the figure is being resized.
In the codebase, it looks like canvas.renderer and canvas.get_renderer() are both used more or less indiscriminately and I doubt anyone took the difference between them into account.
It also makes it harder to write 3rd-party backends (cough cough) which have to provide exactly the same semantics if they want to be swappable to replace the Agg backend.
Given that a renderer whose size/dpi does not match the figure's doesn't really make sense, I think we should deprecate get_renderer() and make .renderer a property that self-replaces when the figure size/dpi changes (or vice-versa deprecate .renderer, but that seems worse on a backcompat code-churn PoV); or, if we really worry about performance, move the renderer-regenerating behavior to e.g. check_renderer_invalidation(). (The cleared=True behavior should also be split out to e.g. get_clean_renderer()).
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!
Activity
timhoffm commentedon Jan 6, 2019
Sounds reasonable. No clear preference on property vs. method.
Is there a need for
get_clean_renderer()at all. This feels like doing two things at once. You can always dosimilar for the property variant.
tacaswell commentedon Jan 6, 2019
Does this relate to #13021 at all?
anntzer commentedon Jan 7, 2019
No(?)
github-actions commentedon May 27, 2023
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!
oscargus commentedon May 30, 2023
An update here is that the
clearedargument was deprecated in 3.6 and will be removed in the upcoming 3.8.