【问题标题】:chaco plot range dynamic updatechaco 绘图范围动态更新
【发布时间】: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)

这一切都很好,除了我想在添加数据后自动调整绘图范围。我看过各种页面建议DataRange2Dvalue_mapper,但我不知道如何使用它们。任何帮助将不胜感激。

【问题讨论】:

  • 我认为如果您删除声明 ylim.low = 0.001ylim.high = 100 它将自动排列。我无法设置可以自动更改的初始限制。
  • 谢谢,我试过了,它适用于线性比例,但不适用于 loglog 比例。

标签: python python-2.7 plot enthought chaco


【解决方案1】:

自动测距:

thisPlot.range2d.y_range.high = 'auto'

具体范围:

thisPlot.range2d.y_range.high = 1000

thisPlot.range2d.y_range.low = .001

您可以通过创建 Bool 特征“enableAutoRange”在两者之间切换。在性状改变时,您可以如上所述设置绘图值。

【讨论】:

    猜你喜欢
    • 2012-03-13
    • 1970-01-01
    • 2022-07-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-23
    • 1970-01-01
    • 2021-09-13
    相关资源
    最近更新 更多