Overlay with VLines and BoxWhisker

Hello,

I want to add some vertical lines on the same plot with boxwhisker

import holoviews as hv
from holoviews import dim
hv.extension('bokeh')

from bokeh.sampledata.autompg import autompg as df

title = "MPG by Cylinders and Data Source, Colored by Cylinders"

boxwhisker = hv.BoxWhisker(
    df, ['cyl', 'origin'], 'mpg', label=title
).opts(
    show_legend=False, width=600, box_fill_color=dim('origin').str(), cmap='Set1'
)

Overlay with list of VLine like

vlines = [hv.VLine(i).opts(color='red', line_width=1.0) for i in range(1, 10, 2)]

import functools
import operator

boxwhisker * functools.reduce(operator.mul, vlines)

works well:

But Overlay with VLines like

vlines = hv.VLines([i in range(1, 10, 2)])
vlines.opts(color='red', line_width=1)

boxwhisker * vlines

prints

:Overlay
   .BoxWhisker.MPG_by_Cylinders_and_Data_Source_comma_Colored_by_Cylinders :BoxWhisker   [cyl,origin]   (mpg)
   .VLines.I                                                               :VLines   [x]

and raises Exception:

...
ValueError: not enough values to unpack (expected 2, got 1)

I think that’s a issue with VLines, so please open a bug report issue on the HoloViews github site.

BTW, instead of having to import functools.reduce, just use the Overlay constructor:

vlines = hv.Overlay([hv.VLine(i).opts(color='red', line_width=1.0) for i in range(1, 10, 2)])
boxwhisker * vlines

Same goes for Layout.

1 Like

Open Overlay with VLines and BoxWhisker · Issue #6055 · holoviz/holoviews · GitHub