【问题标题】:Python Bokeh: remove toolbar from chartPython Bokeh:从图表中删除工具栏
【发布时间】:2015-11-16 11:56:37
【问题描述】:

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

p = figure(toolbar_location=None)


已过时:

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

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)

但是,当我尝试使用散景 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)

有谁知道我做错了什么?

【问题讨论】:

    标签: python bokeh


    【解决方案1】:

    在您可以设置的任何散景图对象上:

    p.toolbar_location = None
    

    【讨论】:

    • 我也试过了(在括号中提到它说 False'' 也不起作用)。但你是对的,根据指南它应该可以工作。不幸的是,它仍然给了我标志和水平线......
    • 你用的是什么版本的散景?
    • bokeh.__version__ 给我0.9.2
    • 很抱歉我的回复晚了 - 在你编辑了你的答案后我没有收到电子邮件,只是认为每个人都忘记了我的问题......你的答案是正确的,我可以删除正如@Merqurio 指出的那样,带有p.logo 的徽标
    【解决方案2】:

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

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

    希望这能解决您的问题

    【讨论】:

    • 如何从 gridPlot 中删除工具栏,从 suplots 中删除无效,无法删除 gridplot:AttributeError: 'Column' object has no attribute 'toolbar'
    • toolbar_location=None,网格图参数
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-07-31
    • 2018-08-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-13
    相关资源
    最近更新 更多