最初的答案是古老且过时的,这是如何使用任何现代版本的Bokeh来实现此目的:
from bokeh.plotting import figure, showimport numpy as npx = np.linspace(0, 2*np.pi)y1 = np.sin(x)y2 = np.cos(x)fig = figure(tools="reset", tooltips=[("x", "$x"), ("y", "$y")])s1 = fig.scatter(x, y1, color='#0000ff', size=10, legend_label='sine')s2 = fig.scatter(x, y2, color='#ff0000', size=10, legend_label='cosine')show(fig)


