How to only link / share only the x-axis?

Is it possible to only have 1 axis linked / shared over 2 plots in holoviews or hvplot?

I basically want my y-axis not be linked / shared, so every plot has a varying range on the y-axis.
But the x-axis should be shared / linked, so that when I make a selection on one plot, the selected x-range is updated on the other plots too.

When I use .opts(axiswise=True) none of the axes is shared and linked anymore.
I could of course change the labels on the y-axis for 1 of the plots, but that feels like cheating.

Code example:

import numpy as np
import pandas as pd

import holoviews as hv
from holoviews import opts
hv.extension('bokeh')

df1 = pd.DataFrame(np.random.rand(10, 2), columns=['x', 'y'])
df2 = pd.DataFrame(np.random.rand(10, 2) * 10, columns=['x', 'y'])

(hv.Scatter(df1) + hv.Scatter(df2)).opts(opts.Scatter(axiswise=True))
3 Likes

I could of course change the labels on the y-axis for 1 of the plots, but that feels like cheating.

This is the only way to achieve this at present, although to be quite clear it is independent of the Dimension label, only the Dimension.name and Dimension.unit matters. I do agree that there are scenarios where linking axes representing the same quantity isn’t desirable of course, but this approach covered the majority of cases. There is some very outdated discussion about this problem here.

For now I can only suggest giving the dimensions different names or units.

Ok, thanks for clarifying, renaming it is :slight_smile:

For my purposes I wish there was something like:

my_plots.opts(axiswise='yaxis')

or if we’re using hvplot then:

df.hvplot.scatter(
    x='x',
    y='y',
    by='z',
    shared_axes='yaxis',
    subplots=True,
)

So possible options for axiswise would be something like: True, False, xaxis, yaxis

3 Likes

Hm, I’m seeing that using curve.relabel(label=‘different_name’) also disconnects the x-axis? Can you confirm that relabeling would leave sharing the x-axis intact?

1 Like