Does Bokeh have the functionality to automatically position a legend in a plot, similar to Matplotlib?
As of Bokeh 0.12.10
, Automatic Legend Placement in Bokeh is still an open feature request that has not yet been implemented.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With