← Back to team overview

yade-dev team mailing list archive

Re: live plot update during simulation

 

Václav Šmilauer said:     (by the date of Tue, 06 Jul 2010 09:39:21 +0200)

> What is this funny thing? :-)
> 
> > + thread.start_new_thread(livePlotLoop,(1,2))
> > +
> > +
> > +def livePlotLoop(dummy1,dummy2):
> 
> 
> Did you read the tutorial section
> http://docs.python.org/tutorial/datastructures.html#tuples-and-sequences
> paragraph starting "A special problem is the construction of tuples
> containing 0 or 1 items"?

hehe, not yet. I am learning by trial & error, google and skimming
this tutorial. So far I have read about 5% of that tutorial ;-))

aha! so it should be () instead of (1,2)


> Hi Janek, this is a great feature, I tried several times and it never
> worked properly. If you notices, the first call to plot.plot() is
> blocking (till you close those plots), while the next ones are not; I
> suspect that this is exactly the issue.

yes, the first call is blocking because of pylab.show().
I found it by trial and error :) In fact I don't know why
pylab.show() is called, because even without it the figure() appears
on the screen.

I made it more apparent in my second diff with livePlotInit parameter.


> A problem is that matplotlib has several backends (Tk, Gtk, Wx) and they
> sould be all supported -- let's see. Another problem is that a a LOT of
> code is duplicated, and it is code that is not easy to read and can be
> buggy.
> 
> Thanks for your contribution, I will try to fix that and merge plot with
> liveplot etc. so that the code is readable.

there's in fact a lot to fix. The biggest problem for me is using
TMP_data. That *sum(..) line is plain magic for me, and I totally
don't understand it. And currently my code works only for uniax.py
but I couldn't get it to work with any other script that does
plotting.

Maybe you could, erm, rewrite that magic line into something longer
that is easier to read and find bugs?

 
> mtTkinter can be added locally to yade, no problem.

I would like to know how you added it lcoally :) I will read your commits.
Especially that part in which I had to use root access to
edit /usr/lib/pymodules/python2.6/matplotlib/backends/tkagg.py


btw, that is its homepage:
  http://tkinter.unpythonic.net/wiki/mtTkinter


best regards
-- 
Janek Kozicki                               http://janek.kozicki.pl/  |



Follow ups

References