【问题标题】:bokeh errors: import error, color gradient error, JS feedback and browser selection散景错误:导入错误、颜色渐变错误、JS反馈和浏览器选择
【发布时间】:2018-03-26 16:33:01
【问题描述】:
from bokeh.core.state import State
from bokeh.io import _CommsHandle, push_notebook
 from bokeh.embed import notebook_div


        ModuleNotFoundError                       Traceback (most recent call last)
        <ipython-input-4-b18f604973b2> in <module>()
        ----> 1 from bokeh.core.state import State
              2 from bokeh.io import _CommsHandle, push_notebook
              3 from bokeh.embed import notebook_div



        ModuleNotFoundError: No module named 'bokeh.core.state'


from add_on import output_notebook, show_figure
from bokeh.io import output_notebook 
from bokeh.plotting import Figure
from bokeh.models import ColumnDataSource


output_notebook()

bokeh.core.state 导入状态是唯一不起作用的导入。 python 版本相同,并且名称中没有带有散景的文件。有人知道发生了什么吗?

仅供参考:我正在尝试创建一个散景图,我可以在其中使用套索选择数据点并将它们放回 jupyter notebook 进行分析。这是我必须创建图表的代码,希望对获取数据点有所了解(假设使用 Javascript)。

    import matplotlib as mpl

    import bokeh.plotting as bpl
    import bokeh.models as bmo

    from bokeh.models import CategoricalColorMapper, ContinuousColorMapper


    TOOLS="hover,crosshair,pan,wheel_zoom,zoom_in,zoom_out,box_zoom,undo,redo,reset,tap,save,box_select,poly_select,lasso_select,"

    def graph_bokeh(algorithm,coordinate_df,metric):


        source = bpl.ColumnDataSource(coordinate_df)

    #     color_map = bmo.CategoricalColorMapper(factors=coordinate_df[metric].unique())

    #     colors = {1:'red',0:'grey'}
        if metric != 'LengthOfStayDaysNBR':
            color_mapper = CategoricalColorMapper(palette=['red','grey'])#,factors = metric)
        else:
            color_mapper = ContinuousColorMapper(palette='Magma256', low=min(coordinate_df[metric]), high=max(coordinate_df[metric]))




        bokeh_graph = figure(width=250, height = 250, title = '{}'.format(str(algorithm)[:3]),tools=TOOLS)

        bokeh_graph.scatter('x-{}'.format(str(algorithm)[:3]),'y-{}'.format(str(algorithm)[:3])\
                            ,color={'field': metric,'transform': color_mapper}\
                            , legend = metric, source = source)



        return bokeh_graph




    for metric in metrics:

        bokeh_graphs = {}
        for i,algorithm in enumerate(algorithms):


             bokeh_graphs[i+1] = graph_bokeh(algorithm,df_algs,metric)

    graph_list = []
    for k,v in bokeh_graphs.items():

        if k%2 == 1 and k!= len(bokeh_graphs):
            graph_list.append([bokeh_graphs[k],bokeh_graphs[k+1]])
        elif k%2 == 1 and k == len(bokeh_graphs):
            graph_list.append([bokeh_graphs[k],None])

    p = gridplot(graph_list)
    show(p)

(对不起三/四部分问题): 我在使用 lengthofstay 度量的颜色渐变时遇到问题(我想为 x/y 坐标着色的第三列)

        color_mapper = ContinuousColorMapper(palette='Magma256', low=min(coordinate_df[metric]), high=max(coordinate_df[metric]))

总是输出蓝色渐变(无论我指定什么调色板)

最后, 图表在 Internet Explorer 中打开,我想要 chrome。

import webbrowser

webbrowser.register("chrome", 无)

好像没用,

也没有 显示(浏览器='chrome')

【问题讨论】:

    标签: python bokeh importerror


    【解决方案1】:

    该模块前段时间移至bokeh.io

    In [3]: from bokeh.io.state import State
    
    In [4]:
    

    请问您为什么认为需要直接使用State?这不是我真正认为普通用户必须使用的东西。它的存在主要是为了方便测试。

    【讨论】:

    • 总体目标是创建具有套索工具的散景图,该工具将 1) x/y 坐标返回或 2) 将索引返回到 python....所以不是绝对必要的。
    猜你喜欢
    • 2021-07-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-13
    • 2014-09-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多