gpt4 book ai didi

python - 能够使用小部件但不能在同一函数中绘图( Bokeh )

转载 作者:太空宇宙 更新时间:2023-11-04 02:42:46 25 4
gpt4 key购买 nike

代码分为两类 - tablerepresentation。我正在使用 bokeh 进行绘图。

当我点击一个小部件时,它会创建一个类 table 并将我带到对象 representation.get_dia(), 它应该给我一行和一个段落。

表中的代码片段

def update_on_button_click():
print(final_data)
rep=representation(final_data)
rep.get_dia()

get_dia() 函数 -

def get_dia(self):
curdoc().clear()
from bokeh.models import Paragraph
p2 = Paragraph(text='Under Construction',width=200, height=100)
p1=figure()
p1.line([1,2,3],[1,2,3])
curdoc().add_root(row(p2,p1))

该函数在浏览器中显示段落但不显示情节。

发生这种情况有什么原因吗?

P.S 如果我从 table 函数调用它,该图是可见的。

最佳答案

#from bokeh.plotting import figure --- adding this (even though I had added 
#this at the starting itself)
def get_dia(self):
#curdoc().clear() --- And Removing this solves the problem
from bokeh.models import Paragraph
p2 = Paragraph(text='Under Construction',width=200, height=100)
p1=figure()
p1.line([1,2,3],[1,2,3])
curdoc().add_root(row(p2,p1))

关于python - 能够使用小部件但不能在同一函数中绘图( Bokeh ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45999806/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com