Matthew Russell
2013-07-05 12:49:18 UTC
I have a series of chaco plots that are dynamically updated with a timer
object. I would like to set the Y ("value" in chaco speak) limits when the
data changes.
When I initialise the plot object I call
obj.alldata = ArrayPlotData(frequency=frequencies)
# Cycle through the channels and add a set to the alldata object
for [i,v] in enumerate(channels):
setname="amplitude{:d}".format(v)
obj.alldata.set_data(setname, empty_amplitude)
for c in config['plots']:
thisplot=Plot(obj.alldata)
xlim=thisplot.index_mapper.range
xlim.low=1
xlim.high=1000
ylim=thisplot.value_mapper.range
ylim.low=0.001
ylim.high=1000
thisplot.plot(("frequency", initdata),
name="Spec",
value_scale="log",
index_scale="log")
container.add(thisplot)
Then, later I update the data array with:
def onTimer(self, *args):
'''This is fired every time the timer is triggered
'''
# Get the data
for [i,v] in enumerate(self.channels):
data=getsimdata(self.s,v,int(self.config['numsamp']))
self.alldata.set_data(setname,data)
This all work fine except I would like to auto range the plot after the
data has been added. I have seen various pages suggest DataRange2D and
value_mapper but I have no idea how to use them. Any help would be much
appreciated as I'm new to Chaco and really like it. I've also asked this
on Stack Overflow
athttp://stackoverflow.com/questions/17488938/chaco-plot-range-dynamic-update
object. I would like to set the Y ("value" in chaco speak) limits when the
data changes.
When I initialise the plot object I call
obj.alldata = ArrayPlotData(frequency=frequencies)
# Cycle through the channels and add a set to the alldata object
for [i,v] in enumerate(channels):
setname="amplitude{:d}".format(v)
obj.alldata.set_data(setname, empty_amplitude)
for c in config['plots']:
thisplot=Plot(obj.alldata)
xlim=thisplot.index_mapper.range
xlim.low=1
xlim.high=1000
ylim=thisplot.value_mapper.range
ylim.low=0.001
ylim.high=1000
thisplot.plot(("frequency", initdata),
name="Spec",
value_scale="log",
index_scale="log")
container.add(thisplot)
Then, later I update the data array with:
def onTimer(self, *args):
'''This is fired every time the timer is triggered
'''
# Get the data
for [i,v] in enumerate(self.channels):
data=getsimdata(self.s,v,int(self.config['numsamp']))
self.alldata.set_data(setname,data)
This all work fine except I would like to auto range the plot after the
data has been added. I have seen various pages suggest DataRange2D and
value_mapper but I have no idea how to use them. Any help would be much
appreciated as I'm new to Chaco and really like it. I've also asked this
on Stack Overflow
athttp://stackoverflow.com/questions/17488938/chaco-plot-range-dynamic-update