[Matplotlib-devel] Figure size and DPI for interactive figures

Thomas Robitaille thomas.robitaille at gmail.com
Sat Sep 19 15:37:50 CEST 2015

Hi everyone,

I've been working on trying to make the canvas in the PyQt5 backend
have a higher resolution on HiDPI/retina displays:


but as part of this, I've become very confused about what we want the
*expected* behavior to be for the DPI setting when making interactive

Let's say that I start from a clean install of Matplotlib, so the
default figure size is (8,6) and the default DPI is 80. If I make a
figure with the MacOS X backend, the figure has the same physical size
relative to other windows in the OS regardless of whether the display
is a retina display or not. However, on retina displays, the canvas is
nice and crisp, so in fact the *real* DPI is 160 not 80. In other
words, the number of pixels in the canvas is *not* (8 * 80, 6 * 80)
but double in each direction. If I now set the DPI to 160, the
*figure* size doubles and the actual DPI stays the same.

With PyQt4, while there is no support for HiDPI/retina displays, I see
the same behavior of the figure size doubling if I double the DPI.

In other words, figure size and DPI do not really mean what they
should mean for interactive figures, and furthermore for the MacOS X
backend on retina displays, the real DPI is double the one in the
settings. So what this means is that (based on the MacOS X backend)
the real figure size is figsize * dpi, and the real DPI is whatever
the screen is.

First, is this all expected behavior? And second, should I try and
implement the same behavior for PyQt5, namely that on HiDPI displays,
a figure with a figure.dpi of 80 will actually look crisp (so it will
be internally doubled)?

Thanks for any advice!


More information about the Matplotlib-devel mailing list