The logic for displaying a figure on the interactive backends (eg qt)
seems a little strange to me. I imagine that normally the screen is
used as a preview for a figure that is going to be output on paper, or
to png or some permanent store. Therefore, the interactive output
should resemble the permanent output as much as possible.
Now, when using the QtAgg backend (sorry no time to play with other
backends) setting the figure height or width has no effect on the size
of the figure displayed with show(). It always comes out at 600x400.
Further, given that the window can be resized or embedded, ideally
what is displayed should be as good a representation of the figure as
possible. It is not, however. To see this try resizing the window -
fonts sizes, linewidths, etc. stay the same size.
I can make the rendering more realistic using the dpi setting. This
can be achieved using this implementation of resizeEvent (from
backend_qt_agg.py / FigureCanvasQtAgg). The original code is
def resizeEvent( self, e ):
FigureCanvasQT.resizeEvent( self, e )
w = e.size().width()
h = e.size().height()
if DEBUG: print "FigureCanvasQtAgg.resizeEvent(", w, ",", h, ")"
#dpival = self.figure.dpi.get()
#winch = w/dpival
#hinch = h/dpival
#self.figure.set_figsize_inches( winch, hinch )
if w/self.figure.get_figwidth() < h/self.figure.get_figheight():
self.figure.set_dpi( w/self.figure.get_figwidth() )
self.figure.set_dpi( h/self.figure.get_figheight() )
The original implementation doesn't really do anything to how the
figure is displayed. The new one makes the plot appear how it should
no matter what the window's size.
This is not ideal, however, as if the figure is saved now the dpi will
be wrong. So there are two questions really: is this a better way
for the interactive windows to display? If so, where should this