The documentation on the hovertemplate is somewhat confusing.
Is there an easy way to provide it (hovertemplate) with arrays of the same length as the traces length?
The basic idea is that when your customdata contains more than a 1d-array i.e it is an array of len(trace data) rows and m>1 columns , then each column k can be passed to hovertemplate in the form
‘%{customdata[k]}’ . Hope that it is not difficult to translate these rules for plotly.js.
Thanks again for all your time! Do I understand correctly then, that there’s no way to show the 4 sub-arrays from the pic above on hover for the four subplots shown on the pic below? E.g. customdata[1][1] should populate the onhover for the second bar in the second column - whatever I tried, I always get the ‘197,087’ instead of ‘14,701’
Each trace in each subplot cell must have defined its own customdata. I do not uhderstand what custom[i][j]
Is in plotly.js for a 2d array, i.e e an array of m rows and n colums. Only columns can be passed to hovertemplate. No other type of subarray.
Awesome - your reply was enough to bring me on the right path. I was providing the same, multi-level customdata to all traces and tried to do the correct assignement in the hovertemplate. Instead, I created 4x customdata and assigned each subplot individually and all works beautifully.
Really easy way if you have pandas. Just choose the columns of interest in a dataframe, convert them to numpy arrays, and form a list of those arrays. This will structure the data perfectly for your ‘customdata’ attribute. Here’s a visual: