how to display figure from a GUI app?

I have a GTK app which runs its matplotlib stuff in a separate
thread. If I call pylab.show() at the end of building the plot
the first time it displays, then after that I have to destroy
the window before it will think about plotting something else,
and it never does (it pretends to - my log message tell me that
it is). If I call pylab.draw() no window is ever displayed. My
GUI is always active.

I would like to pop up a new top-level window for each figure.
How do I do that? My current build-a-plot code looks like this:

    figure = pylab.figure()
    ax = figure.add_subplot(111)
    ax.yaxis.set_major_formatter(pylab.FormatStrFormatter('%.7f'))
    ... build dates and prices lists ...
    ax.plot(dates, prices)
    formatter = matplotlib.dates.DateFormatter('%H:%M:%S')
    ax.xaxis.set_major_formatter(formatter)
    figure.autofmt_xdate()
    ... what goes here? ...

Instead of show() or draw() as the last line what should I be
doing?

Thx,

Skip Montanaro

Which version of matplotlib are you using? There have been numerous improvements to interactivity and multiple calls to show() in version 1.0 and beyond.

There might still be some issues with multiple gui event loops that I think is currently being addressed by the ipython group. Maybe someone else here might be more knowledgeable about that.

I hope that helps!
Ben Root

···

On Wed, Sep 29, 2010 at 3:43 PM, Skip Montanaro <skip@…789…> wrote:

I have a GTK app which runs its matplotlib stuff in a separate

thread. If I call pylab.show() at the end of building the plot

the first time it displays, then after that I have to destroy

the window before it will think about plotting something else,

and it never does (it pretends to - my log message tell me that

it is). If I call pylab.draw() no window is ever displayed. My

GUI is always active.

I would like to pop up a new top-level window for each figure.

How do I do that? My current build-a-plot code looks like this:

figure = pylab.figure()

ax = figure.add_subplot(111)

ax.yaxis.set_major_formatter(pylab.FormatStrFormatter('%.7f'))

... build dates and prices lists ...

ax.plot(dates, prices)

formatter = matplotlib.dates.DateFormatter('%H:%M:%S')

ax.xaxis.set_major_formatter(formatter)

figure.autofmt_xdate()

... what goes here? ...

Instead of show() or draw() as the last line what should I be

doing?

Thx,

Skip Montanaro

We do not support use of pylab or pyplot embedded in a GUI. Rather,
you should embed matplotlib directly using the API. See the
embedding_in_gtk* examples at

http://matplotlib.sourceforge.net/examples/user_interfaces/index.html

JDH

···

On Wed, Sep 29, 2010 at 3:43 PM, Skip Montanaro <skip@...789...> wrote:

I have a GTK app which runs its matplotlib stuff in a separate
thread. If I call pylab.show() at the end of building the plot
the first time it displays, then after that I have to destroy
the window before it will think about plotting something else,
and it never does (it pretends to - my log message tell me that
it is). If I call pylab.draw() no window is ever displayed. My
GUI is always active.