我在bokeh图中的一列中有多个图形。我想同时应用相同的工具转换,即,如果我放大一个图形,则所有图形都应该放大;如果我平移一个图形,则它们都应该平移;如果我重置一个图形,它们都应该重置(我不是很关心悬停,只要有放大、平移和重置就可以了)。
是否有bokeh方法来链接这些图形,或者我需要一些自定义JavaScript代码来实现(如果需要,那么该怎么做)?
谢谢您提前的回答。
编辑:
感谢@bigreddot和@Abhinav提供的解决方案。您需要根据此处的描述使用他们的答案:Linking Plots。范围促进了平移,而相同的数据源促进了缩放。
从layouts示例中修改的解决方案:
是否有bokeh方法来链接这些图形,或者我需要一些自定义JavaScript代码来实现(如果需要,那么该怎么做)?
谢谢您提前的回答。
编辑:
感谢@bigreddot和@Abhinav提供的解决方案。您需要根据此处的描述使用他们的答案:Linking Plots。范围促进了平移,而相同的数据源促进了缩放。
从layouts示例中修改的解决方案:
from bokeh.io import output_file, show
from bokeh.layouts import column
from bokeh.plotting import figure
from bokeh.models import ColumnDataSource
from bokeh.models import PanTool,ResetTool,BoxZoomTool
output_file("layout.html")
x = list(range(11))
y0 = x
y1 = [10 - i for i in x]
y2 = [abs(i - 5) for i in x]
tools=[BoxZoomTool(), PanTool(), ResetTool()]
datasource = ColumnDataSource({'x': x, 'y0': y0, 'y1': y1, 'y2': y2})
# create a new plot
s1 = figure(plot_width=250, plot_height=250, title=None,tools=tools)
s1.circle('x', 'y0', size=10, color="navy", alpha=0.5, source=datasource)
# create another one
s2 = figure(plot_width=250, plot_height=250, title=None,tools=tools,x_range=s1.x_range,y_range=s1.y_range)
s2.triangle('x', 'y1', size=10, color="firebrick", alpha=0.5, source=datasource)
# create and another
s3 = figure(plot_width=250, plot_height=250, title=None,tools=tools,x_range=s1.x_range,y_range=s1.y_range)
s3.square('x', 'y2', size=10, color="olive", alpha=0.5, source=datasource)
# put the results in a column and show
show(column(s1, s2, s3))