File tree 2 files changed +14
-5
lines changed 2 files changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -68,9 +68,9 @@ def paintEvent(self, e):
68
68
# As described in __init__ above, we need to be careful in cases with
69
69
# mixed resolution displays if dpi_ratio is changing between painting
70
70
# events.
71
- if self ._dpi_ratio_prev is None :
72
- self . _dpi_ratio_prev = self . _dpi_ratio
73
- elif self . _dpi_ratio != self ._dpi_ratio_prev :
71
+ if self ._dpi_ratio_prev or self . _dpi_ratio != self . _dpi_ratio_prev :
72
+ # We need to update the figure DPI
73
+ self ._update_figure_dpi ()
74
74
# The easiest way to resize the canvas is to emit a resizeEvent
75
75
# since we implement all the logic for resizing the canvas for
76
76
# that event.
@@ -196,6 +196,10 @@ def __init__(self, figure):
196
196
self .figure ._original_dpi = self .figure .dpi
197
197
self .figure .dpi = self ._dpi_ratio * self .figure ._original_dpi
198
198
199
+ def _update_figure_dpi (self ):
200
+ dpi = self ._dpi_ratio * self .figure ._original_dpi
201
+ self .figure ._set_dpi (dpi , forward = False )
202
+
199
203
200
204
@_BackendQT5 .export
201
205
class _BackendQT5Agg (_BackendQT5 ):
Original file line number Diff line number Diff line change @@ -418,11 +418,16 @@ def _get_axes(self):
418
418
def _get_dpi (self ):
419
419
return self ._dpi
420
420
421
- def _set_dpi (self , dpi ):
421
+ def _set_dpi (self , dpi , forward = True ):
422
+ """
423
+ The forward kwarg is passed on to set_size_inches
424
+ """
422
425
self ._dpi = dpi
423
426
self .dpi_scale_trans .clear ().scale (dpi , dpi )
424
- self .set_size_inches (* self .get_size_inches ())
427
+ w , h = self .get_size_inches ()
428
+ self .set_size_inches (w , h , forward = forward )
425
429
self .callbacks .process ('dpi_changed' , self )
430
+
426
431
dpi = property (_get_dpi , _set_dpi )
427
432
428
433
def get_tight_layout (self ):
You can’t perform that action at this time.
0 commit comments