如何重用python plot.ly update\u点回调?
我有以下函数用于更新python plot.ly中的一个点:如何重用python plot.ly update\u点回调?,python,plotly,plotly-python,Python,Plotly,Plotly Python,我有以下函数用于更新python plot.ly中的一个点: def arbitral_plot_fn(): #定义数据 ... #定义图形小部件 图=。。。 #定义更新点fn def更新点(轨迹、点、选择器): c=列表(散点标记颜色) s=列表(散点标记大小) xs=np.array(points.xs) ys=np.数组(points.ys) 对于i in points.point_inds: 打印(i,结果[i,0]) c[i]=可用的颜色[2] s[i]=20 使用图batch_upd
def arbitral_plot_fn():
#定义数据
...
#定义图形小部件
图=。。。
#定义更新点fn
def更新点(轨迹、点、选择器):
c=列表(散点标记颜色)
s=列表(散点标记大小)
xs=np.array(points.xs)
ys=np.数组(points.ys)
对于i in points.point_inds:
打印(i,结果[i,0])
c[i]=可用的颜色[2]
s[i]=20
使用图batch_update():
scatter.marker.color=c
scatter.marker.size=s
#工作
分散。单击(更新点)
#我更喜欢以下(不起作用)~:
分散。单击(更新点(图=图))#显然会添加一个kwarg来更新点()
图2(图3)
返回
由于update\u point
隐含地要求fig
,因此必须为每个图形重新定义该函数,这会导致大量冗余代码
我可以在每次重新定义时使用lambda来缩短回收时间,每个fig
有没有一种方法可以简单地将fig
作为参数传递给update\u point