草庐IT

Python Bokeh : remove toolbar from chart

coder 2023-05-24 原文

来自维护者的注意事项:这个问题的细节涉及 bokeh.charts API,该 API 已过时并在几年前被删除。在现代 Bokeh 中,指定 toolbar_location:

p = figure(toolbar_location=None)


已过时:

我似乎无法从 Bokeh 条形图中删除工具栏。尽管将 tools 参数设置为 None(或 False''),但我总是以 Bokeh Logo 结束和一条灰线,例如使用此代码:

from bokeh.charts import Bar, output_file, show

# prepare some data
data = {"y": [6, 7, 2, 4, 5], "z": [1, 5, 12, 4, 2]}

# output to static HTML file
output_file("bar.html")

# create a new line chat with a title and axis labels
p = Bar(data, cat=['C1', 'C2', 'C3', 'D1', 'D2'], title="Bar example",
                xlabel='categories', ylabel='values', width=400, height=400,
                tools=None)

# show the results
show(p)

但是,当我尝试使用 Bokeh plot 进行相同操作时,它工作得非常好并且工具栏不见了,例如使用此代码:

from bokeh.plotting import figure, output_file, show

output_file("line.html")

p = figure(plot_width=400, plot_height=400, toolbar_location=None)

# add a line renderer
p.line([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], line_width=2)

show(p)

有谁知道我做错了什么?

最佳答案

如果您想删除 Logo 和工具栏,您可以这样做:

p.toolbar.logo = None
p.toolbar_location = None

希望这能解决您的问题

关于Python Bokeh : remove toolbar from chart,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32158939/

有关Python Bokeh : remove toolbar from chart的更多相关文章

随机推荐