python 函数 veusz 对象
python functions veusz object
您好,我正在尝试使用 Veusz 的面向对象命令行 (https://github.com/jeremysanders/veusz/wiki/EmbeddingPython) 组合一些函数来执行常见任务。 VszPlot(x,y) 应该在嵌入的 window 列表 x 和 y 上创建一个初始图。然后我想要第二个函数 AddPlot(x,y) ,它将新数据添加到同一个嵌入图中。 VszPlot 看起来像这样:
def VszPlot(xval,yval):
#Create a default veusz graph. Visualise with option to save
import veusz.embed as veusz
# construct a Veusz embedded window
# many of these can be opened at any time
handle = veusz.Embedded('Graph')
# construct the plot by adding widgets
page = handle.Root.Add('page')
graph = page.Add('graph')
xy1 = graph.Add('xy',xData = xval, yData = yval)
xy1.MarkerFill.color.val = 'red'
return handle
def AddPlot(handle,xval,yval):
# try and do something to handle
handle.EnableToolbar()
这可行,但是
def AddPlot(handle,xval,yval):
#try and do something to some property of an attribute. eg change colour of markers
handle.graph.xy1.MarkerFill.color.val = 'blue'
如果在 VszPlot 中应用,它将起作用 returns 此错误:
AttributeError: 'Embedded' 对象没有属性 'graph'
我的图形属性哪里去了?
这是 Veusz 特有的问题。当你写 graph=page.Add('graph')
时,Veusz 不知道你给变量的名字。在这里,新图被分配了默认名称 "graph1"。当您使用“.”在树中导航时,您必须使用文档中对象的真实名称。如果你想要一个特定的名字,你可以写page.Add('graph', name='graph')
,或者存储和使用变量graph
。
您好,我正在尝试使用 Veusz 的面向对象命令行 (https://github.com/jeremysanders/veusz/wiki/EmbeddingPython) 组合一些函数来执行常见任务。 VszPlot(x,y) 应该在嵌入的 window 列表 x 和 y 上创建一个初始图。然后我想要第二个函数 AddPlot(x,y) ,它将新数据添加到同一个嵌入图中。 VszPlot 看起来像这样:
def VszPlot(xval,yval):
#Create a default veusz graph. Visualise with option to save
import veusz.embed as veusz
# construct a Veusz embedded window
# many of these can be opened at any time
handle = veusz.Embedded('Graph')
# construct the plot by adding widgets
page = handle.Root.Add('page')
graph = page.Add('graph')
xy1 = graph.Add('xy',xData = xval, yData = yval)
xy1.MarkerFill.color.val = 'red'
return handle
def AddPlot(handle,xval,yval):
# try and do something to handle
handle.EnableToolbar()
这可行,但是
def AddPlot(handle,xval,yval):
#try and do something to some property of an attribute. eg change colour of markers
handle.graph.xy1.MarkerFill.color.val = 'blue'
如果在 VszPlot 中应用,它将起作用 returns 此错误:
AttributeError: 'Embedded' 对象没有属性 'graph'
我的图形属性哪里去了?
这是 Veusz 特有的问题。当你写 graph=page.Add('graph')
时,Veusz 不知道你给变量的名字。在这里,新图被分配了默认名称 "graph1"。当您使用“.”在树中导航时,您必须使用文档中对象的真实名称。如果你想要一个特定的名字,你可以写page.Add('graph', name='graph')
,或者存储和使用变量graph
。