holoviz / holoviews

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

`invert_yaxis` doesn't work in a layout unless `shared_axes=False` #5801

Open droumis opened 1 year ago

droumis commented 1 year ago

ALL software version info

Bokeh: 3.2.0 HoloViews: 1.16.2.post36+g99a3f2079-dirty Panel: 1.2.0

Description of expected behavior and the observed behavior

Invert_yaxis is not working without setting shared_axes=False, and since I need to invert the y-axis of one plot in a layout while keeping the linked interactivity intact, I can't use shared_axes=False.

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

import numpy as np
import xarray as xr
import panel as pn; pn.extension()
import holoviews as hv; hv.extension('bokeh')
import hvplot.xarray
import bokeh

N = 10
data = np.zeros((N, N, N))
indices = np.arange(N)
data[indices, indices, indices] = 1
da = xr.DataArray(data, coords=[("a", indices), ("b", indices), ("c", indices)], name="data")

player = pn.widgets.Player(start=int(da.coords['c'].values.min()), end=int(da.coords['c'].values.max()))

main_view = da.hvplot.image('a', 'b', groupby="c", widgets={"c": player}, width=300, colorbar=False)

neighbor_b = hv.Image(da.mean(['b']), ['a', 'c']).opts(width=300, colorbar=False, invert_yaxis=True) # invert not working without setting shared_axes=False

neighbor_r = hv.Image(da.mean(['a']), ['c', 'b']).opts(width=300, colorbar=False)

pn.Column(f"Bokeh: {bokeh.__version__}<br>HoloViews: {hv.__version__}<br>Panel: {pn.__version__}",
          player, pn.Row(main_view[0], neighbor_r), neighbor_b)

Stack traceback and/or browser JavaScript console output

Screenshots or screencasts of the bug in action

shared_axes=True

image

shared_axes=False

image
hoxbro commented 8 months ago

This seems to be because there is a shared c kdims between the neighbor_b and neighbor_r. Where only neighbor_b has set the c axis to be inverted. A MRE could be this:

import holoviews as hv

hv.extension("bokeh")

data = (range(5), range(5))
plot1 = hv.Points(data, kdims=["c", "b"])
plot2 = hv.Points(data, kdims=["a", "c"]).opts(invert_yaxis=True)

plot1 + plot2

image

And with (plot1 + plot2).opts(shared_axes=False): image

hoxbro commented 8 months ago

Maybe an option like this hv.Points(data, kdims=["a", "c"]).opts(shared_axes=["a"]) could be a way to solve the issue.

MarcSkovMadsen commented 3 months ago

This is also a problem when you use a parent heatmap with a tap stream to drive a child plot as in https://discourse.holoviz.org/t/how-to-keep-yaxis-of-heatmap-inverted-after-tap/7107.