9

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

Sander van den Oord
  • 10,986
  • 5
  • 51
  • 96

1 Answers1

13

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

Sander van den Oord
  • 10,986
  • 5
  • 51
  • 96