Hello, Is there an easy way to set the initial position of a
> Figure? I'm using Windows XP and new figures seem to pop up
> in the typical Windows fashion where subsequent figures
> appear about 20 pixels down and 20 pixels to the right of
> previous figures. How can I tell each figure where to pop up
> on screen?
matplotlib doesn't provide explicit support for this, but it is
possible. What backend are you using. The matplotlib Figure is
embedded in a FigureCanvas which is typically a GUI widget embedded in
a GUI Window. In the pylab interface, the canvas is managed by a
FigureManager, which has a window attribute on most of the backends.
Eg for the GTK backend, for example, you could do
from pylab import *
import gtk
figure(1)
plot([1,2,3])
manager = get_current_fig_manager()
# see gtk.Window class docs at
# Overview — PyGObject
manager.window.set_position(gtk.WIN_POS_CENTER)
figure(2)
plot([1,2,3])
manager = get_current_fig_manager()
# see gtk.Window class docs at
# Overview — PyGObject
manager.window.set_position(gtk.WIN_POS_NONE)
show()
For the WX* backend, manager.window is a wxFrame -
http://www.lpthe.jussieu.fr/~zeitlin/wxWindows/docs/wxwin_wxframe.html#wxframe
For the TkAgg backend, manager.window is a Tkinter.Tk instance -
http://starship.python.net/crew/fredrik/tkclass/ClassToplevel.html
Off the top of my head I don't know the right incantation for each
backend, but hopefully the classdocs I referenced above will help.
Perhaps Todd or Matthew can chime in with more Tk and WX information.
While this arrangement may be suboptimal, we are resisting the urge to
become a GUI library. The temptations to abstract GUI functions for
use in matplotlib are many, and we are trying to keep this to a
manageable core (some event handling, some basic window management,
etc.). It's been on my list of things to do to investigate anygui,
however - http://anygui.sourceforge.net - which would appear to solve
our problems but might require a substantial refactoring of the
matplotlib backends.
If you want full GUI control, you can embed matplotlib in your own GUI
application, following one of the many embedding_in_*.py examples in
the examples subdirectory of the matplotlib src distribution.
If you come up with example code for your backend, please post it to
the list.
JDH