Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Fix qt5 mouse #8440

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Apr 24, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
ENH: setting the DPI properly propagates
Set the figure size back to the current value to push the dpi (and
hence rendered size) change through.
  • Loading branch information
tacaswell committed Apr 17, 2017
commit d739943d85133a9e363ff8560e62ab3e978529f4
22 changes: 13 additions & 9 deletions 22 lib/matplotlib/figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,9 +323,10 @@ def __init__(self,
if frameon is None:
frameon = rcParams['figure.frameon']

self.dpi_scale_trans = Affine2D()
self.dpi = dpi
self.bbox_inches = Bbox.from_bounds(0, 0, *figsize)
self.dpi_scale_trans = Affine2D().scale(dpi, dpi)
# do not use property as it will trigger
self._dpi = dpi
self.bbox = TransformedBbox(self.bbox_inches, self.dpi_scale_trans)

self.frameon = frameon
Expand Down Expand Up @@ -413,6 +414,7 @@ def _get_dpi(self):
def _set_dpi(self, dpi):
self._dpi = dpi
self.dpi_scale_trans.clear().scale(dpi, dpi)
self.set_size_inches(*self.get_size_inches())
self.callbacks.process('dpi_changed', self)
dpi = property(_get_dpi, _set_dpi)

Expand Down Expand Up @@ -710,13 +712,15 @@ def set_size_inches(self, w, h=None, forward=True):
self.bbox_inches.p1 = w, h

if forward:
ratio = getattr(self.canvas, '_dpi_ratio', 1)
dpival = self.dpi / ratio
canvasw = w * dpival
canvash = h * dpival
manager = getattr(self.canvas, 'manager', None)
if manager is not None:
manager.resize(int(canvasw), int(canvash))
canvas = getattr(self, 'canvas')
if canvas is not None:
ratio = getattr(self.canvas, '_dpi_ratio', 1)
dpival = self.dpi / ratio
canvasw = w * dpival
canvash = h * dpival
manager = getattr(self.canvas, 'manager', None)
if manager is not None:
manager.resize(int(canvasw), int(canvash))
self.stale = True

def get_size_inches(self):
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.