Real time plot

Jean-Francois Canac jfcanac at free.fr
Fri Oct 5 04:48:39 EDT 2007


"Lawson Hanson" <lawsonhanson at optusnet.com.au> a écrit dans le message de 
news: 4705e3f5$0$31086$afc38c87 at news.optusnet.com.au...
> Nicholas Bastin wrote:
>> On 10/4/07, Jean-Francois Canac <jfcanac at free.fr> wrote:
>>> mailman.1493.1191484119.2658.python-list at python.org...
>>>> I would draw dots on a suitably sized Tkinter canvas, after drawing a
>>>> schematic
>>>> of the race track (laborious).
>>>>
>>>> 20 per second will be no problem, provided the machine is half decent.
>>>>
>>>> What is the speed at which the com port runs?
>>>>
>>>> - Hendrik
>>>>
>>> The com port run at 19.2 kb/s.
>>> My pb is more the real time aspect: to see the plot changing in real 
>>> time
>>> than the com aspect as the installation is already running with programs 
>>> in
>>> c++.
>>> The PC on which it is running is good enought
>>> For me the interest is to migrate all taht on python to be able to make 
>>> fast
>>> changes when it is of interest
>>
>> The success of this will have more to do with design than programming
>> language.  Any GUI toolkit which allows partial screen updates can be
>> made to update at least as fast as your screen refresh rate, even in
>> python.
>>
>> --
>> Nick
>
> If you are using Tkinter (probably a very good choice), just remember
>     to make periodic (i.e., once per I/O processing loop) calls to:
>
>     Tkinter.update_idletasks()
>
> which will update the display window, etc.
>
> Regards,
>
> Lawson
>
Finally I tried this coding and it works
#==========================
import time
import pylab

pylab.ion()

lat,long,vit = pylab.load(r"c:\pytst\test1.txt",usecols=(1,2,3), 
unpack=True)
lat_min=pylab.amin(lat)
lat_max=pylab.amax(lat)
long_min=pylab.amin(long)
long_max=pylab.amax(long)

print "start"


timefig = pylab.figure(1)
timesub = pylab.subplot(111)
x=[]
y=[]


lines = pylab.plot(x,y)
print lat_min,lat_max,long_min,long_max

for i in range(len(lat)):
 x.append(long[i])
 y.append(lat[i])
 lines[0].set_data(x,y)
 timesub.set_xlim(long_min,long_max)
 timesub.set_ylim(lat_min,lat_max)
 pylab.draw()

#================
The kind of data I have in the text file are just below
Now I have two problems, I think my coding is not very clean as when I try 
yo close or manipulate the windows it generates an error
secondly I think it is a bit slow. I would much prefer something quicker and 
to be able to adapt the speed dynamically with a sleep instruction or 
something as that

09:25:08.50 46.863930 3.161866 56.9 Km/h
09:45:07.75 46.863907 3.161786 11.5 Km/h
09:45:08.0 46.863914 3.161794 12.4 Km/h
09:45:08.25 46.863918 3.161804 13.4 Km/h
09:45:08.50 46.863922 3.161814 14.5 Km/h
09:45:08.75 46.863930 3.161825 15.4 Km/h
09:45:09.0 46.863934 3.161837 16.1 Km/h
09:45:09.25 46.863941 3.161848 16.6 Km/h
09:45:09.50 46.863945 3.161861 17.1 Km/h
09:45:09.75 46.863953 3.161874 17.3 Km/h





More information about the Python-list mailing list