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笔记本中进行分析。这是我创建图表的代码,非常喜欢获取数据点的一些见解(假设使用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”,无)
似乎没有用,
也没有 显示(浏览器= '铬')
答案 0 :(得分:0)
该模块不久前移至bokeh.io
:
In [3]: from bokeh.io.state import State
In [4]:
我可以问你为什么认为你需要直接使用State
吗?对于普通用户来说,这并不是我真正认为必需的东西。它主要用于促进测试。