holoviews
holoviews copied to clipboard
AdjointLayout of Overlays results in different sized side-plots compared to AdjointLayout of regular plots
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:
(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:
(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
I can reproduce; thanks for the report!
Is there a workaround?
As a workaround, you can specify the width and height of the side plots:
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