SourceForge logo
SourceForge logo
Menu

matplotlib-devel

From: James C. <ca...@gm...> - 2005年11月24日 15:23:22
Hi,
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
commented.
 def resizeEvent( self, e ):
 FigureCanvasQT.resizeEvent( self, e )
 w =3D e.size().width()
 h =3D e.size().height()
 if DEBUG: print "FigureCanvasQtAgg.resizeEvent(", w, ",", h, ")"
 #dpival =3D self.figure.dpi.get()
 #winch =3D w/dpival
 #hinch =3D 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() )
 else:
 self.figure.set_dpi( h/self.figure.get_figheight() )
 self.draw()
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
logic go?
thanks,
James
From: John H. <jdh...@ac...> - 2005年11月30日 21:50:13
>>>>> "James" == James Casbon <ca...@gm...> writes:
 James> Hi, The logic for displaying a figure on the interactive
 James> backends (eg qt) seems a little strange to me. I imagine
 James> that normally the screen is used as a preview for a figure
 James> that is going to be output on paper, or to png or some
 James> permanent store. Therefore, the interactive output should
 James> resemble the permanent output as much as possible.
 James> Now, when using the QtAgg backend (sorry no time to play
 James> with other backends) setting the figure height or width has
 James> no effect on the size of the figure displayed with show().
 James> It always comes out at 600x400.
Typically you want saved images to be at a higher resolution than the
one on the screen, since most screens are less than 1500x1500 and
often you want a higher resolution setting. That is why the savefig
command takes a dpi parameter, which default to the settin in your rc
file. You could make the screen dpi and the savefig dpi the same in
rc if you want.
I find that when I resize a figure in the GUI window, the aspect ratio
*is* preserved when I save, so the suggestion above should suffice for
you.
JDH
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /