Single-event-mode plotting

Discussion in 'Python' started by priisdk@gmail.com, Apr 25, 2013.

  1. Guest

    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=testdisplay)
    testdots = visualgraph.gdots(color=color.red,display=testdisplay,size=5)
    mousedots = visualgraph.gdots(color=color.green,display=testdisplay,size=10)
    finalcurve = visualgraph.gcurve(color=color.magenta,display=testdisplay)

    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,yarray))
     
    , Apr 25, 2013
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John J Lee
    Replies:
    3
    Views:
    507
    bruno at modulix
    Dec 1, 2005
  2. Edward Loper
    Replies:
    0
    Views:
    491
    Edward Loper
    Aug 7, 2007
  3. John J Lee
    Replies:
    0
    Views:
    537
    John J Lee
    Aug 7, 2007
  4. Edward Loper

    mmm-mode, python-mode and doctest-mode?

    Edward Loper, Aug 9, 2007, in forum: Python
    Replies:
    0
    Views:
    447
    Edward Loper
    Aug 9, 2007
  5. Neal Becker
    Replies:
    0
    Views:
    393
    Neal Becker
    Aug 9, 2007
Loading...

Share This Page