【发布时间】:2013-07-03 13:26:32
【问题描述】:
我有一系列用计时器对象动态更新的 chaco 图。我想在数据更改时设置 Y ("value" in chaco speak) 限制。
当我初始化我调用的绘图对象时
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)
然后,稍后我将数据数组更新为:
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)
这一切都很好,除了我想在添加数据后自动调整绘图范围。我看过各种页面建议DataRange2D 和value_mapper,但我不知道如何使用它们。任何帮助将不胜感激。
【问题讨论】:
-
我认为如果您删除声明
ylim.low = 0.001和ylim.high = 100它将自动排列。我无法设置可以自动更改的初始限制。 -
谢谢,我试过了,它适用于线性比例,但不适用于 loglog 比例。
标签: python python-2.7 plot enthought chaco