kko
kko

Reputation: 21

Deactivate specific Hover tool in Bokeh html figures?

I want that the pan-tool of Hover toolbar is set OFF when I open the html-page. By default the tool is ON. How to set it off by default? Figure - Trying to "deactivate" pan tool by default

The problem appears to arise when using shared x-axis (grid plot). The command p.toolbar.active_drag = None does not help; pan tool remains active. Any Ideas how to fix this?

Example

from bokeh.plotting import ColumnDataSource, figure, output_file, show,output_notebook,reset_output
from bokeh.models import HoverTool,Grid
from bokeh.layouts import gridplot
import datetime

reset_output()
output_notebook()
tools = 'pan,wheel_zoom,xbox_select,reset'
source = ColumnDataSource(data=dict(time=[2231231233123, 1431231233123, 1731231233123],y=[2, 5, 3],))                         
source2 = ColumnDataSource(data=dict(time=[1231231233123, 1431231233123, 1731231233123],x=[1, 2, 3],))

# Figure 1:
p = figure(width=400, height=200, x_axis_type="datetime",tools=tools)
p.circle('time', 'y', size=20, source=source)
p.toolbar.active_drag = None

# Figure 2:
p2 = figure(x_range=p.x_range,width=400,height=200,x_axis_type="datetime",tools=tools)
p2.circle('time', 'x', size=20, source=source2)
p2.toolbar.active_drag = None

grid = gridplot([p, p2], ncols=1)
show (grid)

Illustrating Example Figure illustrating the problem

Upvotes: 2

Views: 454

Answers (1)

mosc9575
mosc9575

Reputation: 6337

Use

p.toolbar.active_drag = None

You can read more one the official documentation it the section about "setting the active tools".

Minimal Example

from bokeh.plotting import show, figure, output_notebook
output_notebook()

p = figure(width=300, height=300, tools='pan')
p.line([1,2,3,4,5],[1,2,3,4,5])
p.toolbar.active_drag = None
show(p)

Deactivated TapTool

Upvotes: 1

Related Questions