creating new plot after issuing show()

Hi, I have a problem with matplotlib:

    > My program is an interective simulator which needs to
    > re-plot results multiple times at the users request.

    > But after I issue show() I cannot generate other plots.

    > what can I do to circumvent this?

If you are using matplotlib in an application, as it sounds like you
are, you don't need to call show at all. You control the GUI mainloop
yourself. See, for example, examples/ or

Do the application users need to use the matlab interface plotting
commands themselves, or are they simply interacting with the plots
using widgets you provide? If the latter, I suggest not using the
matlab interface at all, and importing Figure from
backends.backend_gtk or backends.backend_wx. and Subplot from axes
and controlling the plots using the object oriented API.

All of the matlab plotting commands are simply thin wrappers to the
Axes API (hist, psd, scatter, etc... are all accessible from the axes


  xlabel('hi mom')
  set(gca(), 'xlim', [0,10])


  fig = Figure(figsize=(5,4), dpi=100)
  ax = Subplot(f, 111)
  ax.set_xlabel('hi mom')

You can force a redraw of the figure by doing


The moral of the story: don't call show for applications; that is for
python batch scripts.

Will this work for you?

Of course if you have a shell and you want to allow your users to
interact with the plot using the matlab interface, you'll need a
different approach. Something along the lines of
examples/, which is an interactive shell for pygtk. I
haven't worked with custom shells for wx, but interactive control of
matplotlib figures works in PyCrust with the CVS version of matplotlib.

Make sure you are using the CVS version of matplotlib as a number of
critical bugs in the WX backend that affect interactive use have been
fixed since the 0.40 release. Note the API for working interactively
has changed. You now do

  import matplotlib

Ditto for GTK.

Here's a snapshot of the latest version in case your CVS mirrors are

Hope this helps!
John Hunter