Limit bokeh plot pan to defined range

主宰稳场 提交于 2019-12-03 16:57:11

The pan/zoom limit feature has been added after this question was first posed.

You can feed the y_range or x_range keyword arguments on a bokeh model a Range1d object with the keyword argument bounds set to a tuple to limit the pan boundaries.

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

fig = figure(y_range=Range1d(bounds=(0, 1)),
             x_range=Range1d(bounds=(0, 1)))

Note that the Range1d's first two positional arguments are for setting the default view-port for an axis, and the bounds is independent of those arguments.


If you want your bounds to be limited by the range values, then you can pass bounds auto:

Range1d(0, 1, bounds="auto")
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!