holoviews icon indicating copy to clipboard operation
holoviews copied to clipboard

AdjointLayout of Overlays results in different sized side-plots compared to AdjointLayout of regular plots

Open peterroelants opened this issue 2 years ago • 3 comments

AdjointLayout of Overlays results in different sized side-plots compared to AdjointLayout of regular plots

For example, the AdjointLayout with Overlays as top and right side plots:

import numpy as np
import holoviews as hv

hv.extension('bokeh')


points_dct = {
    'p1': hv.Points(np.random.randn(1000, 2), kdims=['x', 'y'], label='p1'),
    'p2': hv.Points(np.random.randn(1000, 2) + 2, kdims=['x', 'y'], label='p2')
}


hist_x_dct = {
    k: hv.operation.histogram(p, dimension='y')
    for k, p in points_dct.items()
}

hist_y_dct = {
    k: hv.operation.histogram(p, dimension='x')
    for k, p in points_dct.items()
}

nd_overlay = hv.NdOverlay(points_dct, kdims='cat')
hist_x_nd_overlay = hv.NdOverlay(hist_x_dct, kdims=['cat'])
hist_y_nd_overlay = hv.NdOverlay(hist_y_dct, kdims=['cat'])

nd_overlay << hist_x_nd_overlay << hist_y_nd_overlay

Results in: AdjointOverlay (Notice the square left and top adjoint plots).

While an AdjointLayout that doesn't contain and overlay in the side plots results:

import numpy as np
import holoviews as hv

hv.extension('bokeh')


pts = hv.Points(np.random.randn(1000, 2) , kdims=['x', 'y'], label='p1l')
# pts.hist(dimension=['x','y'])  # Similar effect as line below
pts << hv.operation.histogram(pts, dimension='y')  << hv.operation.histogram(pts, dimension='x')

Results in: AdjointSingular (Notice the expected rectangular left and top adjoint plots).

This was originally notices in the following PR: https://github.com/holoviz/holoviews/pull/5031

software version info

holoviews: 1.14.4.post29+gaf0dd50ad
numpy    : 1.21.1
bokeh    : 2.3.3

peterroelants avatar Sep 01 '21 18:09 peterroelants

I can reproduce; thanks for the report!

jbednar avatar Sep 01 '21 18:09 jbednar

Is there a workaround?

dcherian avatar Jul 20 '22 23:07 dcherian

As a workaround, you can specify the width and height of the side plots:

image

Code
import numpy as np
import holoviews as hv

hv.extension('bokeh')


points_dct = {
    'p1': hv.Points(np.random.randn(1000, 2), kdims=['x', 'y'], label='p1'),
    'p2': hv.Points(np.random.randn(1000, 2) + 2, kdims=['x', 'y'], label='p2')
}


hist_x_dct = {
    k: hv.operation.histogram(p, dimension='y')
    for k, p in points_dct.items()
}

hist_y_dct = {
    k: hv.operation.histogram(p, dimension='x')
    for k, p in points_dct.items()
}

nd_overlay = hv.NdOverlay(points_dct, kdims='cat')
# Changed the following two lines:
hist_x_nd_overlay = hv.NdOverlay(hist_x_dct, kdims=['cat']).opts(width=150, show_legend=False)
hist_y_nd_overlay = hv.NdOverlay(hist_y_dct, kdims=['cat']).opts(height=150, show_legend=False)

nd_overlay << hist_x_nd_overlay << hist_y_nd_overlay

hoxbro avatar Jul 29 '22 10:07 hoxbro