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

前端 未结 4 1880
小鲜肉
小鲜肉 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:20

    Maybe a naive solution, but why not passing the lim axis as argument of your function?

    import numpy
    from bokeh.plotting import figure, show, output_notebook
    output_notebook()
    
    def make_fig(rows=16, cols=16,x_range=[0, 16], y_range=[0, 16], plot_width=500, plot_height=500):
        img = numpy.ones((rows, cols), dtype=numpy.uint32)
        view = img.view(dtype=numpy.uint8).reshape((rows, cols, 4))
        view[:, :, 0] = numpy.arange(256)
        view[:, :, 1] = 265 - numpy.arange(256)
        fig = figure(x_range=x_range, y_range=y_range, plot_width=plot_width, plot_height=plot_height)
        fig.image_rgba(image=[img], x=[0], y=[0], dw=[cols], dh=[rows])
        return fig
    

提交回复
热议问题