Python 将bokeh绘图范围限制在规定范围内

Python 将bokeh绘图范围限制在规定范围内,python,bokeh,Python,Bokeh,我想知道是否有可能限制bokeh生成图的“平移”工具的范围?例如,假设我有一个简单的情节: from bokeh.plotting import output_file, rect, show output_file('test.html') rect([10,20,30], [10,20,30], width=[1,2,3], color=['red','blue','green'], height=5, plot_width=400, plot_height=400, tools = "yp

我想知道是否有可能限制bokeh生成图的“平移”工具的范围?例如,假设我有一个简单的情节:

from bokeh.plotting import output_file, rect, show
output_file('test.html')
rect([10,20,30], [10,20,30], width=[1,2,3], color=['red','blue','green'], height=5, plot_width=400, plot_height=400, tools = "ypan,box_zoom,reset")
show()

ypan工具工作得很好,但我可以一直平移直到图形消失。有什么方法可以限制平移吗?

首次提出此问题后,添加了平移/缩放限制功能

您可以将关键字参数
bounds
设置为元组以限制平移边界,将
y\u范围
x\u范围
关键字参数输入bokeh模型a
Range1d
对象

from bokeh.plotting import figure
from bokeh.models import Range1d

fig = figure(y_range=Range1d(bounds=(0, 1)),
             x_range=Range1d(bounds=(0, 1)))
请注意,
Range1d
的前两个位置参数用于设置轴的默认视口,边界与这些参数无关


如果希望边界受到范围值的限制,则可以传递边界
auto

Range1d(0, 1, bounds="auto")

如何对字符串列表而不是0>1@azazelspeaks哈哈,哇