获取当前Bokeh图的轴宽

时间:2016-01-26 15:07:50

标签: javascript python bokeh

使用Bokeh服务器时,我需要知道Bokeh轴的当前宽度(自创建以来可能通过使用resize工具改变了大小)。

figure.plot_width仅打印图形的总宽度,包括刻度标签,轴标签和边距,而不是轴区域的宽度。此外,在调整数字大小时,它似乎无法更新。

如何在Bokeh服务器中获取当前轴宽?

最小示例,显示bokeh serve plot_width.py

# file name: plot_width.py

import bokeh.plotting
import numpy

def print_current_plot_width():
    print "Current plot width: ", p.plot_width

x = numpy.linspace(0, 10, 100)
y = x + numpy.random.random(100)

p = bokeh.plotting.figure(x_range=[0, 10], tools='resize')
l = p.line(x, y)

print "Initial plot width: ", p.plot_width

bokeh.plotting.curdoc().add_periodic_callback(print_current_plot_width , 1000)

bokeh.plotting.curdoc().add_root(p)

0 个答案:

没有答案
相关问题