Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Single-event-mode plotting

Reply
Thread Tools

Single-event-mode plotting

 
 
priisdk@gmail.com
Guest
Posts: n/a
 
      04-25-2013
I have some questions on the example below. My intention is to replace the y values with data from some sensor connected to the computer, and to make it work in what could be called 'single-event-mode' which means that I onlywant to plot and store data whenever the mouse is clicked.
I have made the plotting with VPython, and I have also considered matplotlib.
However, with either of these modules I cannot see how to answer the questions 1 and 2 below.
Is there some other graphical module that will be better suited?
Notice, that I use Python 3.2.

1) Can I modify the program so that the clicks should be done in the testdisplay window on not in the scene window?

2) In the testdisplay I only want to see the actual blue point together with the hitherto stored green points. And not only that: I want to free all earlier blue points from memory. How can I do that?



Poul Riis



from time import *
import visual.graph as visualgraph
from visual import *

scene=display(x=0, y=0, width=300, height=100,foreground=color.black,
background=color.white)
ch=''
txt=''
inputtext='tmax: '
labeltext=label(pos=(0,0,0),text=inputtext)
while ch!='\n':
ch=scene.kb.getkey()
txt=txt+ch
if ch!='\n':
labeltext.text=inputtext+txt
tmax=eval(txt)
#labeltext.visible=0


testdisplay=visualgraph.gdisplay(title='Test', xtitle='x', ytitle='y',
x=0, y=75, width=500, height=500,foreground=color.black,
background=color.white)
testcurve = visualgraph.gcurve(color=color.blue,display=testdi splay)
testdots = visualgraph.gdots(color=color.red,display=testdisp lay,size=5)
mousedots = visualgraph.gdots(color=color.green,display=testdi splay,size=10)
finalcurve = visualgraph.gcurve(color=color.magenta,display=tes tdisplay)

tarray=[]
yarray=[]
tstart=time()
t=time()-tstart
while t<tmax:
rate(10)
t=time()-tstart
y=sin(5*pi*t/tmax)
nevents=scene.mouse.events
testcurve.plot(pos=(t,y))
testdots.plot(pos=(t,y))
if nevents>1:
mousedots.plot(pos=(t,y))
scene.mouse.events = 0
tarray.append(t)
yarray.append(y)
for i in range(0,len(tarray)):
finalcurve.plot(pos=(tarray[i],yarray[i]))
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating And Plotting Graphs morc Java 2 02-23-2006 08:22 PM
data plotting Thomas Nelson Java 2 05-17-2005 08:45 AM
Plotting points on a web page Carl Gilbert ASP .Net 1 03-07-2005 11:34 PM
Plotting data under VisualBasic 5.0 or the VBA included with MSWord97or MSAccess97 Richard Owlett Computer Support 0 10-01-2003 08:57 PM
plotting API? =?ISO-8859-1?Q?Per-Olav_Rus=E5s?= Java 2 07-07-2003 01:13 PM



Advertisments