Convert multiple legends in hv.layout to single legend

Dear all,

How can i convert multiple legends in hv.layout to single legend

here is the code of hvplot to hv.layout

test_north=(rsl_2g[(rsl_2g.RBU==f'North')].\
groupby(['RBU','Comm_Region','hour'])['Sector'].count().reset_index(name='Down_Sectors').hvplot.line(\
x='hour',y='Down_Sectors',by=['Comm_Region'],\
).relabel('2G').opts(toolbar=None,show_grid=True,width=400)+\
rsl_4g[(rsl_4g.RBU==f'North')].\
groupby(['RBU','Comm_Region','hour'])['Cell Name'].count().reset_index(name='Down_Sectors').hvplot.line(\
x='hour',y='Down_Sectors',by=['Comm_Region'],\
).relabel('4G').opts(toolbar=None,show_grid=True,width=400)+\
rsl_3g[(rsl_3g.RBU==f'North')].\
groupby(['RBU','Comm_Region','hour'])['Cell Name'].count().reset_index(name='Down_Sectors').hvplot.line(\
x='hour',y='Down_Sectors',by=['Comm_Region'],\
).relabel('3G').opts(toolbar=None,show_grid=True,width=400)).cols(3)

OutPut highlighted three legends


Required how to convert all the same legends to single legend

hv.layout

I tried and stuck here.

plot1 = (hv.Curve([0, 1, 2], label="a") * hv.Curve([5, 6, 7], label="b")).opts("Curve", show_legend=False)
plot2 = (hv.Curve([0, 1, 2], label="a") * hv.Curve([5, 6, 9], label="b"))
plot1 + plot2

2 Likes

@ahuang11 Thanks for the solution the resultant plot is Layout
image

How do i implement in hvplot or access Layout.Ndoverlay.Curve options separately

Can you share a minimal, reproducible example (MRE)?

In general a complete script that can be copy/pasted and immediately run, as-is, with no modifications. This is much more useful than snippets.

Just call opts on the one you want to edit.

df.hvplot(“x”, “y”).opts(…) + df.hvplot(“x”, “y”)

1 Like