How can I accomplish `set_xlim` or `set_ylim` in Bokeh?

前端 未结 4 1879
小鲜肉
小鲜肉 2020-12-03 06:53

I create a figure in a function, e.g.

import numpy
from bokeh.plotting import figure, show, output_notebook
output_notebook()

def make_fig():
    rows = col         


        
4条回答
  •  情深已故
    2020-12-03 07:23

    One way is to can things with a simple tuple when creating a figure:

    figure(..., x_range=(left, right), y_range=(bottom, top))
    

    But you can also set the x_range and y_range properties of a created figure directly. (I had been looking for something like set_xlim or set_ylim from matplotlib.)

    from bokeh.models import Range1d
    
    fig = make_fig()
    left, right, bottom, top = 3, 9, 4, 10
    fig.x_range=Range1d(left, right)
    fig.y_range=Range1d(bottom, top)
    show(fig)
    

提交回复
热议问题