工具栏自动隐藏#
此示例展示了如何激活一个工具栏,当光标离开画布时,该工具栏会消失。
详情
- Bokeh APIs:
figure.circle,bokeh.models.autohide- More info:
- Keywords:
自动隐藏,工具栏
import numpy as np
from bokeh.layouts import row
from bokeh.plotting import figure, show
N = 1000
x = np.random.random(size=N) * 100
y = np.random.random(size=N) * 100
radii = np.random.random(size=N) * 1.5
colors = np.array([(r, g, 150) for r, g in zip(50+2*x, 30+2*y)], dtype="uint8")
def make_plot(autohide=None):
p = figure(width=300, height=300, title='Autohiding toolbar' if autohide else 'Not autohiding toolbar')
p.circle(x, y, radius=radii, fill_color=colors, fill_alpha=0.6, line_color=None)
p.toolbar.autohide = autohide
return p
show(row(make_plot(True), make_plot(False)))