On Thu, Jul 1, 2010 at 10:42 AM, ninjasmith <henrylindsaysmith@gmail.com> wrote:



>
> Hi,
>
> I think what you are after is the interactive mode of matplotlib. You can
> turn
> is on by "ion" and redraw the current figure using "draw". In ipythons
> "pylab"
> mode this is done implicit. I attached some example lines which guide you
> to
> the right direction. I'm not sure why I need two draws in my attached
> script,
> but at least it seems to do the job.
> For more infos you may visit:
> http://matplotlib.sourceforge.net/users/shell.html#controlling-interactive-
> updating
>
> Kind regards,
> Matthias
>
>
> import numpy as np
> import sys
> import matplotlib.pylab as pyp
>
> a = np.array([0, 4, 5, 5, 3, 4, 5])
> pyp.ion()
> pyp.figure()
> pyp.plot(a)
> pyp.draw()
> pyp.draw()
>
> input = sys.stdin.readline()
> print "input 1 : %s " % (input)
> pyp.xlabel('my xlabel %s' % input)
> pyp.draw()
> pyp.draw()
>
> input = sys.stdin.readline()
> print "input 2 : %s " % (input)
>
> pyp.ioff()
> pyp.show()
>
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by Sprint
> What will you do first with EVO, the first 4G phone?
> Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>

that almost fixes it.  I can now plot and re draw during the execution of my
script.  However I cannot interact with the plots.  i.e. I can't zoom in on
an area.  when the script gets to the point where pyp.show() is called then
I'm able to do this.  I'm thinking there may be no way round this?

or is there some way to run matplot lib plot in a different thread?


ipython does this, I believe, when you call it with the -pylab option, but I have never tried it with a script.

Ben Root