|
From: Seth M. <sm...@ps...> - 2011-06-09 02:37:58
|
Hello all, I am trying to develop an application that can display how a function changes as different parameters are altered. For example, let's say that I want to plot y = sin(kx). I have a slider that controls the value of k, and I then replot the function with the new k whenever the slider is moved. By default, it appears that the gcurve object keeps all previously plotted data on the gdisplay. While I can envision situations where this is a benefit (like for binning a histogram), for this application I would like only plot the current value of k and not retain the plot of all previous values. In other words, I would like to reset the gcurve object before replotting with the new k. I haven't found an any easy way to reset the gcurve object without deleting the gdisplay object and then opening a new one. Is there an easy way to reset the gcurve object? Thanks, Seth Morton |
|
From: Poul R. <Pou...@sk...> - 2011-06-11 18:50:54
|
Bru...@nc... writes:
>There's something missing in the documentation. The following sequence
>will erase the gcurve. When you create a gcurve object, one of its
>pieces is a curve object, and you can get at that curve object as
>shown here.
>
>f = gcurve(.....)
>.....
>f.gcurve.pos = []
I woud guess that there are similar commands for gvbars and gdots.
However, this seems not to be the case. The (dummy) example below can only
delete the gcurve and ends with an error message.
Poul Riis
from visual.graph import *
from time import *
oscillation = gdisplay(xtitle='Time', ytitle='Response')
funct1 = gcurve(color=color.cyan)
funct2 = gvbars(delta=0.5, color=color.red)
funct3 = gdots(color=color.yellow)
for t in arange(-30, 74, 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)) )
histo = gdisplay(title='Histogram', x=0, y=400, width=800,height=400)
datalist1 = [5, 37, 12, 21, 25, 28, 8, 63, 52, 75, 7]
data = ghistogram(bins=arange(-20, 80, 10), color=color.red)
data.plot(data=datalist1)
datalist2 = [7, 23, 25, 72, -15]
data.plot(data=datalist2, accumulate=1)
print 'Wait 2 seconds...'
sleep(2)
print 'Deleting a gcurve...'
funct1.gcurve.pos = []
print 'Wait 2 seconds...'
sleep(2)
print 'Deleting vbars...'
funct2.gvbars.pos = []
print 'Wait 2 seconds...'
sleep(2)
print 'Deleting gdots...'
funct3.gdots.pos = []
|
|
From: Bruce S. <Bru...@nc...> - 2011-06-11 21:01:30
|
If you examine site-packages/vis/graph.py you'll see that gdots is implemented a self.dots = points(), gvbars is implemented as self.vbars = faces(), and ghbars is implemented as self.hbars = faces(). Clearly, what should be done is implement graphobject.clear(). I'll put it on a list. Bruce Sherwood On Sat, Jun 11, 2011 at 12:32 PM, Poul Riis <Pou...@sk...> wrote: > > > Bru...@nc... writes: > There's something missing in the documentation. The following sequence > will erase the gcurve. When you create a gcurve object, one of its > pieces is a curve object, and you can get at that curve object as > shown here. > f = gcurve(.....) > ..... > f.gcurve.pos = [] > I woud guess that there are similar commands for gvbars and gdots. However, > this seems not to be the case. The (dummy) example below can only delete the > gcurve and ends with an error message. > Poul Riis > > > from visual.graph import * > from time import * > oscillation = gdisplay(xtitle='Time', ytitle='Response') > funct1 = gcurve(color=color.cyan) > funct2 = gvbars(delta=0.5, color=color.red) > funct3 = gdots(color=color.yellow) > for t in arange(-30, 74, 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)) ) > histo = gdisplay(title='Histogram', x=0, y=400, width=800,height=400) > datalist1 = [5, 37, 12, 21, 25, 28, 8, 63, 52, 75, 7] > data = ghistogram(bins=arange(-20, 80, 10), color=color.red) > data.plot(data=datalist1) > datalist2 = [7, 23, 25, 72, -15] > data.plot(data=datalist2, accumulate=1) > print 'Wait 2 seconds...' > sleep(2) > print 'Deleting a gcurve...' > funct1.gcurve.pos = [] > print 'Wait 2 seconds...' > sleep(2) > print 'Deleting vbars...' > funct2.gvbars.pos = [] > print 'Wait 2 seconds...' > sleep(2) > print 'Deleting gdots...' > funct3.gdots.pos = [] > > > > ------------------------------------------------------------------------------ > EditLive Enterprise is the world's most technically advanced content > authoring tool. Experience the power of Track Changes, Inline Image > Editing and ensure content is compliant with Accessibility Checking. > http://p.sf.net/sfu/ephox-dev2dev > _______________________________________________ > Visualpython-users mailing list > Vis...@li... > https://lists.sourceforge.net/lists/listinfo/visualpython-users > > |
|
From: Bruce S. <Bru...@nc...> - 2011-06-09 03:34:05
|
There's something missing in the documentation. The following sequence will erase the gcurve. When you create a gcurve object, one of its pieces is a curve object, and you can get at that curve object as shown here. f = gcurve(.....) ..... f.gcurve.pos = [] Bruce Sherwood On Wed, Jun 8, 2011 at 8:37 PM, Seth Morton <sm...@ps...> wrote: > Hello all, > > I am trying to develop an application that can display how a function changes as different parameters are altered. For example, let's say that I want to plot y = sin(kx). I have a slider that controls the value of k, and I then replot the function with the new k whenever the slider is moved. By default, it appears that the gcurve object keeps all previously plotted data on the gdisplay. While I can envision situations where this is a benefit (like for binning a histogram), for this application I would like only plot the current value of k and not retain the plot of all previous values. In other words, I would like to reset the gcurve object before replotting with the new k. > > I haven't found an any easy way to reset the gcurve object without deleting the gdisplay object and then opening a new one. Is there an easy way to reset the gcurve object? > > Thanks, > > Seth Morton > > > > > ------------------------------------------------------------------------------ > EditLive Enterprise is the world's most technically advanced content > authoring tool. Experience the power of Track Changes, Inline Image > Editing and ensure content is compliant with Accessibility Checking. > http://p.sf.net/sfu/ephox-dev2dev > _______________________________________________ > Visualpython-users mailing list > Vis...@li... > https://lists.sourceforge.net/lists/listinfo/visualpython-users > |