While trying to create a dynamic map I noticed a strange behaviour concerning the legend position in an overlay. The following code recreates the problem I came across.
import pandas as pd
import holoviews as hv
from holoviews import opts
import panel as pn
hv.extension('bokeh')
pn.extension()
data = {'name': ['nick', 'david', 'joe', 'ross','nick', 'david', 'joe', 'ross','nick', 'david', 'joe', 'ross'],
'year': [2010,2010,2010,2010,2011,2011,2011,2011,2012,2012,2012,2012],
'grade': [5, 10, 7, 6, 8, 9, 8, 10, 4, 6, 5, 5],
'age' : [8,9,10,11,9,10,11,12,10,11,12,13]
}
new = pd.DataFrame.from_dict(data)
ds = hv.Dataset(new)
heatmap = hv.HeatMap(ds, kdims=['name','year'], vdims='grade')
posxy = hv.streams.Tap(source=heatmap, x='nick', y='2010')
def tap_curves(x,y):
ds = hv.Dataset(new.query('name =="'+ x +'"' ))
curve1 = hv.Curve(ds,'year','grade', label='GRADE')
curve2 = hv.Curve(ds,'year','age', label='AGE')
layout = curve1 * curve2
layout.opts(opts.Curve(framewise=True),
opts.Overlay(title=x, legend_position='left', ylabel=''))
return layout
dmap = hv.DynamicMap(tap_curves, streams=[posxy])
layout = heatmap + dmap
pn.Pane(layout).show()
If you place the legend inside the graph at line 25 e.g. top_left everything works fine but ussually they are overlaping with the curves