Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 21e0a2e

Browse files
committed
Remove print_figure overrides in backend subclasses
AFAICT, `print_figure` is only called in `savefig`, and thus has no relation to backend drawing. We went through a lot of trouble to make `savefig` self-contained, so if this really had any effect, it would be a bug in it instead. But other backends don't do this override and seem to work fine, so these seem superfluous as well. After this change, just opening a window in Qt and using the save button did not seem to break anything, nor did running `savefig` with an interactive window open. I did not test Wx, but given the callers of `print_figure`, I don't see how it could be different. Fixes matplotlib#5234
1 parent 690884f commit 21e0a2e

File tree

2 files changed

+0
-13
lines changed

2 files changed

+0
-13
lines changed

lib/matplotlib/backends/backend_qtagg.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,6 @@ def paintEvent(self, event):
7171
finally:
7272
painter.end()
7373

74-
def print_figure(self, *args, **kwargs):
75-
super().print_figure(*args, **kwargs)
76-
self.draw()
77-
7874

7975
@_BackendQT.export
8076
class _BackendQTAgg(_BackendQT):

lib/matplotlib/backends/backend_wx.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -614,15 +614,6 @@ def gui_repaint(self, drawDC=None):
614614
'xpm': 'X pixmap',
615615
}
616616

617-
def print_figure(self, filename, *args, **kwargs):
618-
# docstring inherited
619-
super().print_figure(filename, *args, **kwargs)
620-
# Restore the current view; this is needed because the artist contains
621-
# methods rely on particular attributes of the rendered figure for
622-
# determining things like bounding boxes.
623-
if self._isDrawn:
624-
self.draw()
625-
626617
def _on_paint(self, event):
627618
"""Called when wxPaintEvt is generated."""
628619
_log.debug("%s - _on_paint()", type(self))

0 commit comments

Comments
 (0)