Bokeh的hovertool inipython拒绝显示工具提示

时间:2014-12-01 05:26:53

标签: ipython ipython-notebook bokeh mpld3

我直接复制并粘贴了如何使用bokeh文档中的悬停工具的例子,我仍然无法让这个该死的东西工作。我只想要散景的悬停工具来显示x和y坐标。我想我已经正确地实现了它,但是如果有什么不对的地方让我知道。 (ASCII文件读取完美,图形正确,所有其他工具都可以工作)

from bokeh.plotting import *
from bokeh.objects import HoverTool
from collections import OrderedDict
output_notebook()

 %matplotlib inline 
 import numpy as np
 import matplotlib
 import matplotlib.pyplot as plt

 import mpld3
 from mpld3 import plugins, utils
 mpld3.enable_notebook()


 from pylab import *
 import pandas as pd

 chip1 = pd.io.parsers.read_table("Chip1_Buffer_ASCII", sep=";")
 chip2 = pd.io.parsers.read_table("Chip2_Buffer_ASCII", sep=";")
 chip3 = pd.io.parsers.read_table("Chip3_Buffer_ASCII", sep=";")
 chip1_1=chip1
 chip1_2=chip2
 chip1_3=chip3
 chip1_1["Frequency (Hz)"]=chip1["Frequency (Hz)"].map(lambda x: math.log10(x))
 chip1_2["Frequency (Hz)"]=chip2["Frequency (Hz)"].map(lambda x: math.log10(x))
 chip1_3["Frequency (Hz)"]=chip3["Frequency (Hz)"].map(lambda x: math.log10(x))

  diff_1_2 = chip1 - chip2
 diff_1_2["Frequency (Hz)"] = chip1_1["Frequency (Hz)"]


 source1 = ColumnDataSource(chip1_1.to_dict("list"))
 source2 = ColumnDataSource(chip1_2.to_dict("list"))
 source3 = ColumnDataSource(chip1_3.to_dict("list"))
 source4=ColumnDataSource(diff_1_2.to_dict("list"))

 import bokeh.plotting as bk

 bk.figure(plot_width=600, # in units of px
       plot_height=600,
       title="Hello World!",
       tools="pan,wheel_zoom,box_zoom,select,reset,hover")
 bk.hold()


bk.line("Frequency (Hz)", "-Phase (°)",line_width=2,source=source1,logx=True,color="red",xlim=[0, 10000])
bk.line("Frequency (Hz)", "-Phase (°)",line_width=2,source=source2,logx=True,color="green",xlim=[0, 10000])
bk.line("Frequency (Hz)", "-Phase (°)",line_width=2,source=source3,logx=True,color="orange",xlim=[0, 10000])
bk.line("Frequency (Hz)", "-Phase (°)",line_width=2,source=source4,logx=True,color="orange",xlim=[0, 10000])
hover = bk.curplot().select(dict(type=HoverTool))
hover.tooltips=OrderedDict([
    ("(x,y)", "($x, $y)"),
    ("index", "$index")
])

bk.show()

0 个答案:

没有答案