holoviews icon indicating copy to clipboard operation
holoviews copied to clipboard

Layout of overlays doesn't scale properly with axiswise=True

Open emield12 opened this issue 2 years ago • 3 comments

ALL software version info

bokeh==2.4.2 holoviews==1.14.8 python==3.8.12

Description of expected behavior and the observed behavior

When using the axiswise=True option I expect every plot to be scaled independently and not share axes. But when using a Layout of two Overlays this doesn't work, the axes are shared and scaled on all data. When removing any element from the plot (sa, sb, sc or sd) it works correctly. I've demonstrated this below with hv.Scatter objects but I have the same problem with hv.Image and hv.RGB (I did not test with other objects).

Complete, minimal, self-contained example code that reproduces the issue

import holoviews as hv
import numpy as np
hv.extension("bokeh")

sa = hv.Scatter(data = np.random.random((100, 2))).opts(axiswise=True)
sb = hv.Scatter(data = np.random.random((100, 2))).opts(axiswise=True)

sc = hv.Scatter(data = np.random.random((100, 2))*100).opts(axiswise=True)
sd = hv.Scatter(data = np.random.random((100, 2))*100).opts(axiswise=True)

sa * sb + sc * sd

Screenshots or screencasts of the bug in action

Wrong behavior: image

Correct behavior when only using three elements (sa * sb + sc): image

emield12 avatar Apr 01 '22 08:04 emield12

Hi Can any of the devs confirm this is a bug @philippjfr @jlstevens @jbednar and not the intended behavior? I'm willing to spend some time to fix this bug, but would appreciate some clues on where I can start to search.

Cheers! Emiel

emield12 avatar May 07 '22 15:05 emield12

To get this to work with axiswise=True you need to also add it to the overlays:

sa = hv.Scatter(data = np.random.random((100, 2))).opts(axiswise=True)
sb = hv.Scatter(data = np.random.random((100, 2))).opts(axiswise=True)

sc = hv.Scatter(data = np.random.random((100, 2))*100).opts(axiswise=True)
sd = hv.Scatter(data = np.random.random((100, 2))*100).opts(axiswise=True)

(sa * sb).opts(axiswise=True) + (sc * sd).opts(axiswise=True)

An alternative way to do it is to redim one of the overlays like this:

sa = hv.Scatter(data = np.random.random((100, 2)))
sb = hv.Scatter(data = np.random.random((100, 2)))

sc = hv.Scatter(data = np.random.random((100, 2))*100)
sd = hv.Scatter(data = np.random.random((100, 2))*100)

(sa * sb).redim(x="x1", y="y1") + sc * sd

But the easiest way is to use shared_axes=False on the last overlay.

sa = hv.Scatter(data = np.random.random((100, 2)))
sb = hv.Scatter(data = np.random.random((100, 2)))

sc = hv.Scatter(data = np.random.random((100, 2))*100)
sd = hv.Scatter(data = np.random.random((100, 2))*100)

(sa * sb + sc * sd).opts(shared_axes=False)

hoxbro avatar May 08 '22 06:05 hoxbro

Personally, I find this very confusing, and I can't ever remember what I need to do, how it is meant to work when axiswise=True is only set on individual plots (why doesn't just setting it on the overlay do it?), and how those relate to shared_axes. I think this needs addressing in the docs.

jbednar avatar May 16 '22 20:05 jbednar

There's even a third option called linked_axis described here: https://discourse.holoviz.org/t/axiswise-true-does-not-work/1018/2?u=linuxiscool

I've been confused by this topic so many times. I would really appreciate some clear documentation.

LinuxIsCool avatar Nov 16 '23 16:11 LinuxIsCool