From: Bruce S. <bas...@un...> - 2003-01-20 04:11:57
|
Here is a little program that plots a graph and displays (x,y) whenever the left mouse button is down. from visual.graph import * oscillation = gdisplay(title='Test Plotting', xtitle='Time', ytitle='Response') funct1 = gcurve(color=color.cyan) funct2 = gvbars(color=color.red, delta=0.8) funct3 = gdots(color=color.yellow) for t in arange(-30, 76, 1): funct1.plot(pos=(t, 5.0+5.0*cos(-0.2*t)*exp(0.015*t)) ) funct2.plot(pos=(t, 2.0+5.0*cos(-0.1*t)*exp(0.015*t)) ) funct3.plot(pos=(t, 5.0*cos(-0.03*t)*exp(0.015*t)) ) showxy = label(display=oscillation.display, yoffset=10, line=0, opacity=1, visible=0) while 1: rate(300) m = oscillation.display.mouse if m.button == 'left': showxy.pos = (m.pos.x,m.pos.y) showxy.text = '%d,%d' % (m.pos.x,m.pos.y) showxy.visible = 1 else: showxy.visible = 0 |