如何在Bokeh中实现`set_xlim`或`set_ylim`的功能?

14 浏览
0 Comments

如何在Bokeh中实现`set_xlim`或`set_ylim`的功能?

在函数中创建一个图形,例如:

import numpy
from bokeh.plotting import figure, show, output_notebook
output_notebook()
def make_fig():
    rows = cols = 16
    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=[0, c], y_range=[0, rows])
    fig.image_rgba(image=[img], x=[0], y=[0], dw=[cols], dh=[rows])
    return fig

然后,我想放大图形:

fig = make_fig()
# <- 放大图形,类似于 matplotlib 的 set_xlim
show(fig)

如何在 bokeh 中进行编程式放大?

0