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
Sander's response is correct and will solve your specific problem, but in this case it may not be addressing the root cause. HoloViews only links axes that are the same, and it sounds like you're plotting different quantities on the y axis in each plot. In that case, the real fix is to put in a real name for the y axis of each plot, something that distinguishes it from other things that you might want to plot on the y axis in some other plot you're showing. Then not only will HoloViews no longer link the axes inappropriately, the viewer of your plot will be able to tell that each plot is showing different things.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With