Python Bokeh: remove toolbar from chart

Question:

Note from maintainers: The specifics of this question concern the bokeh.charts API which is obsolete and was removed several years ago. In modern Bokeh, specify toolbar_location:

p = figure(toolbar_location=None)


OBSOLETE:

I don’t seem to be able to remove the toolbar from a bokeh Bar chart. Despite setting the tools argument to None (or False or ) I always end up with the bokeh logo and a grey line, e.g. with this code:

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)

However, when I try the same with a bokeh plot, it works perfectly fine and the toolbar is gone, e.g. with this code:

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)

Does anyone know what I’m doing wrong?

Asked By: Arkady

||

Answers:

On any Bokeh plot object you can set:

p.toolbar_location = None
Answered By: Luke Canavan

If you want to remove the logo and the toolbar you can do:

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

Hope this resolves your problem

Answered By: merqurio
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.