Plots do not show with bokeh

99封情书 提交于 2021-02-11 14:15:57

问题


i am trying to export a report as HTML using Bokeh with python. Can anybody tell me, why my code is not working? I tried to print a simple Div and succeeded, but as soon as i include plots, the browser still opens, but nothing is visible. Is it not possible to inherit Figure?

I reduced it to the relevant parts:

def export_html(self):
    plots=[]
    plots.append(PlotObject(self.plot_attributes[4]))
    VisuLog(plots)


from bokeh.plotting import Figure, show, output_file

class VisuLog():
    def __init__(self,plots):
       self.plots = plots
       filename="Report_"
       output_file("visu_out\\"+ filename + ".html", title=filename)
       show(self.plots)  # open a browser

class PlotObject(Figure):
   def __init__(self,plot_attributes):
       super(PlotObject, self).__init__()

Thank you for your help.


回答1:


Try adding

__subtype__ = 'PlotObject'
__view_model__ = 'Plot'

to the body of the PlotObject class.

But I would advise against extending Bokeh objects unless you want to provide some UI behavior by writing custom JavaScript/TypeScript implementation.



来源:https://stackoverflow.com/questions/61636793/plots-do-not-show-with-bokeh

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!