You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何移除Bokeh绘制图表中的灰色网格边框?

你需要移除的浅灰色边线是Bokeh绘图对象默认的轮廓边框,只需要在现有代码中新增一行修改轮廓线颜色的配置即可。

核心修改语句:
p.outline_line_color = None

修改后的完整可运行代码如下:

from bokeh.models import Range1d
from bokeh.plotting import figure, output_file, show

output_file('test.html')

p = figure(width=300, height=100, toolbar_location=None)
p.rect(x=0.5*60, y=0.5, width=60, height=1)

p.xgrid.grid_line_color = None
p.ygrid.grid_line_color = None
p.axis.visible = False
p.x_range = Range1d(0, 100)
p.toolbar.active_drag = None
# 移除外围灰色轮廓边框
p.outline_line_color = None

show(p)

你也可以通过设置p.outline_line_width = 0达到同样的隐藏效果。

内容的提问来源于stack exchange,提问作者dropout

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.25 05:24:06