user2662485
user2662485

Reputation: 1

multiple curves on single vPython plot

I would like to put two curves on one vPython plot. Is this possible?

I am opening the curve with:

gd = gdisplay(x=300, y=0, width=600, height=600,
  title='Entropy', xtitle='time', ytitle='N',
  foreground=color.black, background=color.red,
  xmax=250, xmin=0, ymax=400, ymin=0.)
funct1=gcurve(color=color.white)

I am updating for a single curve inside a while loop with

funct1.plot(pos=(bigIndex,entropy))

Along with plotting the entropy on this graph, I'd like to plot the number of particles in a particular position. One set of axis, two curves. I would like each curve to be undated inside the loop so the students can see one curve grow as the other decreases.

Is this possible?

Upvotes: 0

Views: 924

Answers (1)

Markus
Markus

Reputation: 592

Simply create another gcurve object. Then update both curves simultanously in your while loop using the plot command. Example:

from visual import *
from visual.graph import *
gd = gdisplay(x=300, y=0, width=600, height=600,
  title='Entropy', xtitle='time', ytitle='N',
  foreground=color.black, background=color.white,
  xmax=250, xmin=0, ymax=400, ymin=0.)
funct1=gcurve(color=color.black)
funct2=gcurve(color=color.black)

for i in range(0,200):
  funct1.plot(pos=(i,i*2))
  funct2.plot(pos=(i,400-i*2))
  rate(20)

Upvotes: 1

Related Questions