Thanks to this post, I am able to share only the x-axis between two curves in holoviews:
t = np.arange(100)
data1 = np.random.rand(100)
data2 = np.random.rand(100) + 100
curve1 = hv.Curve((t, data1), 'time', 'y1')
curve2 = hv.Curve((t, data2), 'time', 'y2')
hv.Layout(curve1 + curve2)
Now I am trying to do the same between a curve and a quadmesh, but without success... I have seen Share x-axis between Bokeh plots but it uses only the bokeh api and I would like to use holoviews.
The code without the x-axis shared would be the following:
t = np.arange(100)
data1 = np.random.rand(100)
data_mesh = np.random.rand(10, 100)
curve1 = hv.Curve((t, data1), 'time', 'y1')
curve2 = hv.QuadMesh((t, np.arange(10), data_mesh)) # What should I add here ?
hv.Layout(curve1 + curve2)
I tried some options, such as relabel the x-axis but without success. How should I do ?
Any help would be very appreciated ! Thanks
In HoloViews, axes are shared if they are considered to have the same Dimension. Dimensions are considered the same if they have the same name and (optional) label, so simply changing the label is not enough to make it match a Dimension on another plot with a different name. See the user guide for the details, but here you can change the QuadMesh to declare that its x dimension is the same as the one from the Curve.
import numpy as np, holoviews as hv
hv.extension("bokeh")
t = np.arange(100)
data1 = np.random.rand(100)
data_mesh = np.random.rand(10, 100)
curve1 = hv.Curve((t, data1), 'time', 'y1')
curve2 = hv.QuadMesh((t, np.arange(10), data_mesh)).redim(x='time')
curve1 + curve2