2015-05-29 93 views
2

我使用散景將〜700模擬的結果與另一組使用散點圖的結果進行比較。我想使用懸停工具通過分配標識模擬參數的自定義索引來定性確定數據中的模式。如何使用Bokeh懸停工具顯示自定義索引?

在下面的代碼中,xy是來自Pandas DataFrame的列,它具有索引的模擬ID。我已經能夠使用<DataFrameName>.index.values將這個索引分配給一個數組,但我還沒有找到任何關於如何爲索引指定懸停工具的文檔。

# Bokeh Plotting 
h = 500 
w = 500 
default_tools = "pan, box_zoom, resize, wheel_zoom, save, reset" 
custom_tools = ", hover" 
fig = bp.figure(x_range=xr, y_range=yr, plot_width=w, plot_height=h, tools=default_tools+custom_tools) 
fig.x(x, y, size=5, color="red", alpha=1) 
bp.show(fig) 

回答

2

configuring the hover tool的文檔有一個例子,說明如何做到這一點。這裏是我使用的代碼:

from bokeh.models import ColumnDataSource, HoverTool 
cds = ColumnDataSource(
    data=dict(
     x=xdata, 
     y=ydata, 
     desc=sim 
    ) 
) 
hover = HoverTool() 
hover.tooltips = [ 
     ("Index", "$index"), 
     ("(2z,1z)", "($x, $y)"), 
     ("ID", "@desc") 
] 
相關問題