Skip to content

Commit b7e881f

Browse files
committed
Don't change Figure DPI if value unchanged
Check that the value of dpi is different before going through all the machinery to actually flush the change of value.
1 parent e702edd commit b7e881f

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

‎lib/matplotlib/figure.py‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -442,11 +442,12 @@ def _set_dpi(self, dpi, forward=True):
442442
forward : bool
443443
Passed on to `~.Figure.set_size_inches`
444444
"""
445-
self._dpi = dpi
446-
self.dpi_scale_trans.clear().scale(dpi)
447-
w, h = self.get_size_inches()
448-
self.set_size_inches(w, h, forward=forward)
449-
self.callbacks.process('dpi_changed', self)
445+
if self._dpi != dpi:
446+
self._dpi = dpi
447+
self.dpi_scale_trans.clear().scale(dpi)
448+
w, h = self.get_size_inches()
449+
self.set_size_inches(w, h, forward=forward)
450+
self.callbacks.process('dpi_changed', self)
450451

451452
dpi = property(_get_dpi, _set_dpi, doc="The resolution in dots per inch.")
452453

0 commit comments

Comments
 (0)