能够使用小部件但不能在同一函数中绘图(散景)
Able to use widget but not plot in the same function (bokeh)
代码分为两个 classes - table
和 representation.
我正在使用 bokeh 进行绘图。
当我点击一个小部件时,它会创建一个 class table
并将我带到对象 representation.get_dia(),
,这应该给我一行和一个段落。
来自 table
的代码片段
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))
代码分为两个 classes - table
和 representation.
我正在使用 bokeh 进行绘图。
当我点击一个小部件时,它会创建一个 class table
并将我带到对象 representation.get_dia(),
,这应该给我一行和一个段落。
来自 table
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))