使用Holoviews / Hvplot更改图例位置

10
Hvplot 默认将图例放置在绘图区域的右侧外部。
如何更改默认的图例位置?
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

1个回答

15
您可以通过在代码中添加.opts(legend_position='top_left')来将图例位置更改为左上方。
df.hvplot.line().opts(legend_position='top_left')
如果您想将图例放在图表内部,可以从以下选项中进行选择:

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

如果您希望将图例放在图表外部,可以从以下选项中选择:

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

enter image description here


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接