8

I am trying to create a Holomap figure in holoviews that includes a legend at the top of the plot.

The configuration option "legend_position" works fine for a non-holomap figure ("example1.html" below), but not for the holomap ("example2.html" below).

import pandas as pd
import holoviews as hv

df = pd.DataFrame(dict(x=[1, 2], y1=[0, 1], y2=[1, 0], y3=[0.8, 0.8], y4=[0.2,0.2]))
curve1 = hv.Curve(df, 'x', 'y1', label='curve1').opts(ylabel='y')
curve2 = hv.Curve(df, 'x', 'y2', label='curve2').opts(ylabel='y')
curve3 = hv.Curve(df, 'x', 'y3', label='curve3').opts(ylabel='y')
curve4 = hv.Curve(df, 'x', 'y4', label='curve4').opts(ylabel='y')

cc12 = (curve1 * curve2).opts(legend_position='top')
hv.save(cc12, "example1.html")

cc34 = (curve3 * curve4).opts(legend_position='top')
hm = hv.HoloMap({'a':cc12, 'b':cc34}, kdims=["option"])
hm = hm.opts(legend_position='top')
hv.save(hm, "example2.html")

I think this has something to do with the position of the legend not being allowed outside of the plot in the holomap case. So the answer the question might simply be "It is not supposed to work". The problem is that for some plots the default legend overlaps with the curves, making the curves hard to interpret.

magum
  • 597
  • 1
  • 5
  • 12

1 Answers1

0

Created a github issue for this:
https://github.com/holoviz/holoviews/issues/4191

This is now fixed in HoloViews 1.13, which is the upcoming release.

If you would already like to have the latest version of HoloViews, you can install it with:

pip install git+https://github.com/holoviz/holoviews.git

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