Reputation: 5641
Does Bokeh have the functionality to automatically position a legend in a plot, similar to Matplotlib?
Upvotes: 6
Views: 1590
Reputation: 562
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.
Upvotes: 3
Reputation: 2137
Yes. Just set the legend.location attribute as one of the enumerable locations (i.e. 'top_left' or 'bottom_right'):
Upvotes: -2
Reputation: 34568
As of Bokeh 0.12.10
, Automatic Legend Placement in Bokeh is still an open feature request that has not yet been implemented.
Upvotes: 2