Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide legend in bokeh plot

Tags:

python

plot

bokeh

LS, Bokeh plot automatically generates a legend for a plot. How can I hide (not show at all) the legend in a Bokeh plot ? I tried: legend = 'none'. But no success. Thanks

like image 334
ArtDijk Avatar asked Aug 25 '16 09:08

ArtDijk


2 Answers

p1.line(x=data['col'].astype(str), y=data['col'],
     color='black',legend_label='legend')
p1.legend.visible=False 

The last line hides the legend.

like image 160
Joselin Ceron Avatar answered Oct 10 '22 09:10

Joselin Ceron


If I can just expand this a little - legend=False is the correct way to make the Bokeh legend invisible, but it's used within the creation of the plot itself, rather than being called as an attribute of the plot object. By which I mean, write

from bokeh.charts import Scatter
myPlot = Scatter(foo, bar, legend=False)

rather than

from bokeh.charts import Scatter
myPlot = Scatter(foo, bar)
myPlot.legend=False.
like image 25
amunnelly Avatar answered Oct 10 '22 09:10

amunnelly