Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change legend position using holoviews / hvplot

Hvplot has default the position of the legend on the right outside of the plot.
How can I change this default legend position?

import numpy as np
import pandas as pd
import hvplot
import hvplot.pandas
import holoviews as hv

data = np.random.normal(size=[50, 2])
df = pd.DataFrame(data, columns=['a', 'b'])
df.hvplot.line()

enter image description here

like image 671
Sander van den Oord Avatar asked Sep 05 '19 15:09

Sander van den Oord


1 Answers

You can change the legend position to top left by adding .opts(legend_position='top_left') to your code.

df.hvplot.line().opts(legend_position='top_left')

If you would like to position your legend inside your plot, you can choose from the following options:

['top_right', 'top_left', 'bottom_left', 'bottom_right']

If you want to place your legend outside your plot, you can choose from these options:

['right', 'left', 'top', 'bottom']

enter image description here

like image 147
Sander van den Oord Avatar answered Nov 16 '22 00:11

Sander van den Oord