I'm using Holoviews to construct a dashboard of charts. Some of these charts have percentages in the y axis where as others have sums/counts etc. When I try to output all the charts I have created to a html file, all the charts change their y axis to match the axis of the first chart of my chart list.
For example:
when I combine these charts in holoviews using:
The y axis of charts 2 and 3 become the same as chart 1.
Does anyone know why this is happening and how I can fix it so all the charts keep their individual axis pertinent to what they are trying to represent.
Thank you!
This happens when the y-axes have the same name.
You need to use option axiswise=True if you want every plot to get its own independent x-axis and y-axis.
There's a short reference to axiswise in the holoviews FAQ:
https://www.holoviews.org/FAQ.html
Here's a code example that I've checked and works:
# import libraries etc.
import numpy as np
import pandas as pd
import holoviews as hv
from holoviews import opts
hv.extension('bokeh')
# create some sample data
df1 = pd.DataFrame({
'x': np.random.rand(10),
'y': np.random.rand(10),
})
df2 = pd.DataFrame({
'x': np.random.rand(10) * 10,
'y': np.random.rand(10) * 10,
})
# set axiswise=True so that every plot gets its own independent x- and y-axis
plot1 = hv.Scatter(df1).opts(axiswise=True)
plot2 = hv.Scatter(df2).opts(axiswise=True)
plot1 + plot2
Or alternatively you can do:
plot1 = hv.Scatter(df1)
plot2 = hv.Scatter(df2)
(plot1 + plot2).opts(opts.Scatter(axiswise=True))
If this doesn't work when you try my code example, you may have to upgrade to the latest version of holoviews. This can be done as follows:
Install the latest git versions of holoviews, hvplot, panel, datashader and param