###Graph Snippet ##Make sure you include the following in the import section from visual.graph import * ##Each graph must be created and named graph1 = gdisplay(x=0, y=0, width=600, height=550, title='Velocity vs. Time', xtitle='t(s)', ytitle='V (m/s)', xmax=20., xmin=0., ymax=200, ymin=0, foreground=color.white, background=color.black) ##You need tp define gcurve objects to graph velPlot1 = gcurve(color=color.red) velPlot2 = gcurve(color=color.yellow) while ball1.y> 0.: if scene.mouse.clicked: ball1.pos = ball1.pos + ball1.velocity*dt ball1.velocity = ball1.velocity+ball1.acceleration*dt ball2.pos = ball2.pos + ball2.velocity*dt ball2.velocity = ball2.velocity+ball2.acceleration*dt ######################How you pass info to the graph############### velPlot1.plot(pos=(time,ball1.y)) velPlot2.plot(pos=(time,ball2.y)) ################################################################### if ball1.velocity.y < 0: ball1.acceleration.y = -9.81 + 0.5*Cp1*ball1.A*dot(ball1.velocity,ball1.velocity)/(ball1.mass) else: ball1.acceleration.y = -9.81 - 0.5*Cp1*ball1.A*dot(ball1.velocity,ball1.velocity)/(ball1.mass) if ball2.velocity.y < 0: ball2.acceleration.y = -9.81 + 0.5*Cp2*ball2.A*dot(ball2.velocity,ball2.velocity)/(ball2.mass) else: ball2.acceleration.y = -9.81 - 0.5*Cp2*ball2.A*dot(ball2.velocity,ball2.velocity)/(ball2.mass) time = time + dt