matplotlib and boa

Hello,

I've been trying to use matplotlib from boa constructor (on windows,
running enthon-python2.4-1.0.0 and boa-constructor 0.4.4). For test
purpose I have a single button-event call this function:

def testPlot():
  plot([1,2,3])
  show()

Everything is fine for the first event - button fires the function and
a plot-window is showing. Killing this window and have a second go at
the plot at first seems to work but the window can not be closed and
when I try to move said window the whole application crash.

So - why is this happening?

regards,
Sture

···

--
Sture Lygren
Computer Systems Administrator
Andoya Rocket Range
Work: +4776144451 / Fax: +4776144401

I've been trying to use matplotlib from boa constructor (on windows,
running enthon-python2.4-1.0.0 and boa-constructor 0.4.4). For test
purpose I have a single button-event call this function:

def testPlot():
        plot([1,2,3])
        show()

Everything is fine for the first event - button fires the function and
a plot-window is showing. Killing this window and have a second go at
the plot at first seems to work but the window can not be closed and
when I try to move said window the whole application crash.

There is a conflict between the GUI library used by boa constructor
(wxWidgets/wxPython) and the one used by default by matplotlib when
you run the show() command (Tk).

Each of these two libraries run an event loop, handling all your
keyboard and mouse inputs. When you start your application, wxWidgets
has control. When you run show(), Tk takes control and displays your
matplotlib chart. But when you close the chart window, Tk keeps
control, so your application freezes.

The solution is to use another backend, compatible with wxpython. Try
backend WX or WXAgg.

At the top of your script (before import pylab), add this:
import matplotlib
matplotlib.use('WX')

or:
import matplotlib
matplotlib.use('WXAgg')

More explanations here: http://matplotlib.sourceforge.net/backends.html

For reference, here is information provided on matplotlib's web site:
http://matplotlib.sourceforge.net/installing.html
There are known conflicts with some of the backends with some python
IDEs such as pycrust, idle. If you want to use matplotlib from an IDE,
please consult backends for compatibility information. You will have
the greatest likelihood of success if you run the examples from the
command shell or by double clicking on them, rather than from an IDE.
If you are interactively generating plots, your best bet is TkAgg from
the standard python shell or ipython.

Good luck!

-- Nicolas Grilly

Hi,

Thank's a lot for your informative answer. I've solved the issue now using
WXAgg as backend. WX was way too slow (plotting two graphs with 8000
datapoints each)

regards,
Sture

···

I've been trying to use matplotlib from boa constructor (on windows,
running enthon-python2.4-1.0.0 and boa-constructor 0.4.4). For test
purpose I have a single button-event call this function:

def testPlot():
        plot([1,2,3])
        show()

Everything is fine for the first event - button fires the function and
a plot-window is showing. Killing this window and have a second go at
the plot at first seems to work but the window can not be closed and
when I try to move said window the whole application crash.

There is a conflict between the GUI library used by boa constructor
(wxWidgets/wxPython) and the one used by default by matplotlib when
you run the show() command (Tk).

Each of these two libraries run an event loop, handling all your
keyboard and mouse inputs. When you start your application, wxWidgets
has control. When you run show(), Tk takes control and displays your
matplotlib chart. But when you close the chart window, Tk keeps
control, so your application freezes.

The solution is to use another backend, compatible with wxpython. Try
backend WX or WXAgg.

At the top of your script (before import pylab), add this:
import matplotlib
matplotlib.use('WX')

or:
import matplotlib
matplotlib.use('WXAgg')

More explanations here: http://matplotlib.sourceforge.net/backends.html

For reference, here is information provided on matplotlib's web site:
http://matplotlib.sourceforge.net/installing.html
There are known conflicts with some of the backends with some python
IDEs such as pycrust, idle. If you want to use matplotlib from an IDE,
please consult backends for compatibility information. You will have
the greatest likelihood of success if you run the examples from the
command shell or by double clicking on them, rather than from an IDE.
If you are interactively generating plots, your best bet is TkAgg from
the standard python shell or ipython.

Good luck!

-- Nicolas Grilly

--
Sture Lygren
Computer Systems Administrator
Andoya Rocket Range
Work: +4776144451 / Fax: +4776144401

Happy to know it have solved your issue :slight_smile:

NG

···

On 2/14/07, Sture Lygren <sture@...1466...> wrote:

Thank's a lot for your informative answer. I've solved the issue now using
WXAgg as backend. WX was way too slow (plotting two graphs with 8000
datapoints each)