Does Bokeh have the functionality to automatically position a legend in a plot, similar to Matplotlib?
Asked
Active
Viewed 1,483 times
3 Answers
2
As of Bokeh 0.12.10
, Automatic Legend Placement in Bokeh is still an open feature request that has not yet been implemented.

bigreddot
- 33,642
- 5
- 69
- 122
2
I found a way to make it automatic for the position at least.
mid = int(df.shape[0]/2)
v1, v2 = df[:mid].sum().sum(), df[mid:].sum().sum()
fig.legend.location = 'top_right' if v1 > v2 else 'top_left'
you can play around with it and add else if statements to specific position it or even do the same for the colours. Also you need to lock the column that you will be plotting, in this case I let it opened in my dataset I did so.
-2
Yes. Just set the legend.location attribute as one of the enumerable locations (i.e. 'top_left' or 'bottom_right'):

bigreddot
- 33,642
- 5
- 69
- 122

Luke Canavan
- 2,107
- 12
- 13
-
Sorry if I wasn't clear, I wanted the legend to position itself automatically, not manually by specifying a location. Did you see the link in the question? – user666 Aug 17 '16 at 23:47