How to link the axis in multiple holoviews plots?

1.5k views Asked by At

I have created to datashader plots with holoviews:

datashade(hv.Points(df[
    [
        'PS Engine-% Load', 
        'PS Engine-Fuel Rate',
    ]
])) + datashade(hv.Points(df[
    [
        'SB Engine-% Load', 
        'SB Engine-Fuel Rate',
    ]
]))

Both graphs are plotted fine, now I want to link the ranges of the axis so when I zoom in one graph the other graph is also zoomed in the same way. From what I understand normally axis are linked when the source values are the same. In this case the sources for both the X and Y axis are different (note the PS and SB values) but the ranges are the same. How can I link these axis?

1

There are 1 answers

3
James A. Bednar On BEST ANSWER

Yes, HoloViews will automatically link dimensions that it considers to be "the same", where "the same" comes down to having the same name and unit. In this case, probably the easiest thing to do is to make sure the dimensions you want to link have the same column name in the dataframe:

df_ps = df.rename(columns={'PS Engine-% Load': '% Load'})
df_sb = df.rename(columns={'SB Engine-% Load': '% Load'})
datashade(hv.Points(df_ps[['% Load','PS Engine-Fuel Rate']])) + \
datashade(hv.Points(df_sb[['% Load','SB Engine-Fuel Rate']]))

If the Fuel Rate should also be linked, just add that to the rename dictionary for each one as well. Example before zooming:

Without zooming in

and after zooming in:

After zooming in