Skip to content

Commit db30cbe

Browse files
committed
MNT: restore the old DPI when resetting the canvas
This prevent the figures from growing on hi-dpi screens.
1 parent 06b97a8 commit db30cbe

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

lib/matplotlib/figure.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3003,7 +3003,12 @@ def _set_base_canvas(self):
30033003
This is used upon initialization of the Figure, but also
30043004
to reset the canvas when decoupling from pyplot.
30053005
"""
3006+
# check if we have changed the API due to hi-dpi screens
3007+
orig_dpi = getattr(self, '_original_dpi', self._dpi)
30063008
FigureCanvasBase(self) # Set self.canvas as a side-effect
3009+
# put it back to what it was
3010+
if orig_dpi != self._dpi:
3011+
self.dpi = orig_dpi
30073012

30083013
def set_canvas(self, canvas):
30093014
"""

0 commit comments

Comments
 (0)