Link behavior changes depending on the order of the plots

Hi all. Here is a possible bug: when plotting a bar plot and a line plot with what I think is a linked x axis (how can I verify the x axes of both plots are linked?), the linking works when the bar plot comes first but it stops working if we plot the line plot first. (more precise description after the code) Here is the code:

# data
n = 10
dates = pd.date_range('2019-01-01', periods=n)
counts = np.random.randint(0, 13, size=n)
df = pd.DataFrame({
    'date': dates,
    'counts': counts,
    'ecdf': counts.cumsum() / counts.sum()
})
df['ecdf'] = counts.cumsum() / counts.sum()


# plots
plot = {
    'counts': hv.Bars(df, 'date', 'counts').opts(xrotation=45, width=600, height=300),
    'ecdf': hv.Curve(df, 'date', 'ecdf').opts(xrotation=45, width=600, height=300)
}


# PROBLEM: switching the order of the plots by switching the comment
# below leads to different link behavior.
# Link works when counts/bar plot on top, but not when ECDF/line on top.
#
# (plot['ecdf'] + plot['counts']).cols(1)
(plot['counts'] + plot['ecdf']).cols(1)

What I mean by “the linking works in one order but not in the other” is:

  • When the counts/bars are first, you can box zoom into, say, the lower right corner and see the plot change in the ecdf/line plot.
  • When you flip the order of the plots, you can no longer get a box zoom in one plot to do anything to the other plot.

Is this normal, am I missing something? If not, I’d be happy to file a bug in the issue tracker.

Thanks everyone for all the work on this library and the PyViz ecosystem!

Conda env:

# some key pkgs installed widh conda (on a Macbook Pro 2019, Mojave):
#
# bokeh                     1.4.0                    py37_0
# holoviews                 1.12.7                     py_0
# numpy                     1.17.4           py37hc1035e2_0
# pandas                    1.0.1            py37h0573a6f_0
# python                    3.7.4                h265db76_1
# jupyter                   1.0.0                    py37_7  
# jupyter_core              4.6.1                    py37_0  
# jupyterlab                1.2.6                      py_0    conda-forge

This seems like a bug related to linking of categorical and numerical axes. In future releases the linking code will take into account the type of axes before linking which should avoid this issue. The appearance that it “works” in one case is because it actually replaces the numerical with a categorical axis, which I’d actually consider a bug.

Thanks for the response. I will need some time to understand what you just said.

Either way, I’m happy to file a bug if you want, or test this in a future release. Just let me know when you think the code will be released, and I’ll set a reminder for myself.

Sorry if that wasn’t clear. Basically the issue is that Bars use a categorical axis and Curve uses a numeric axis by default. If the two get linked, then the last plot will inherit the axis from the previous one, which only works correctly in some cases. In future these two axis types will no longer get automatically linked and in the longer term Bars will hopefully be able to handle a numerical x-axis correctly.

Thank you, that was much more clear.

So right now there is no “correct” way of linking them but this may be corrected in the future?

Again, happy to file a bug if needed.