【发布时间】: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