holoviz / holoviews

With Holoviews, your data visualizes itself.
https://holoviews.org
BSD 3-Clause "New" or "Revised" License
2.69k stars 402 forks source link

Calling `.collate()` on a layout deletes its label #3795

Open cristi-neagu opened 5 years ago

cristi-neagu commented 5 years ago

Hello,

Running this code produces a layout without a label. Is this normal?

import numpy as np
import holoviews as hv
from holoviews import opts

hv.extension('bokeh')

x = np.random.normal(0, 1, 10000)
y = np.random.normal(0, 1, 10000)
data1 = {'x' : x, 'y' : y}
data2 = {'x' : x+2, 'y' : y*2}

sctr1 = hv.Scatter(data1).opts(tools=['hover'])
sctr2 = hv.Scatter(data2).opts(tools=['hover'])
ovr = hv.Overlay([sctr1, sctr2], label='Overlay')

ovr.collate()

I know that in this case there is no need to use collate(), but the point is that simply calling ovr will work and will produce a plot with a label, so it's clear that collate() removes the label.

Is this intended? Am i doing something wrong?

Thank you.

poplarShift commented 5 years ago

Could you elaborate on your use case? collate does not specifically delete anything, it just creates a new Overlay:

def collate(self):
    """
    Collates any objects in the Overlay resolving any issues
    the recommended nesting structure.
    """
    return reduce(lambda x,y: x*y, self.values())
cristi-neagu commented 5 years ago

I'm trying to overlay a datashaded image and a decimated scatter plot to get some hover info out of the plot. This is then part of a layout. In essence, something like:

hv.Layout([ovr, hv.Overlay([datashade(sctr2), sctr1])])

Yes, there is probably a correct way of doing that. But the point still stands: Why is .collate() removing the label when it's called?