侧面面板中的 ScaleBar 绘制在图形外部
作者: ghostiee-11创建于 2026年8月30日更新于 2026年8月30日
from bokeh.io import output_file, save from bokeh.layouts import gridplot from bokeh.models import Metric, Range1d, ScaleBar from bokeh.plotting import figure output_file("scalebar.html")
p = figure(width=300, height=120, toolbar_location="above") p.line([1, 2, 3], [1, 2, 3]) p.add_layout( ScaleBar( range=Range1d(0, 10), unit="m", dimensional=Metric(base_unit="m"), orientation="vertical", ), "right", ) save(gridplot(children=[[p]]))
Stack traceback or browser console output
Nothing is logged, this fails silently. The saved page's console only contains Bokeh's own startup lines:
[bokeh 3.10.0] setting log level to: 'info'
[bokeh 3.10.0] document idle at 74 ms内容来源: bokeh/bokeh