Multicategory xaxis label arrangement is not proper

Multicategory xaxis labels arrangement is not proper in plotting (doesn’t match the arrangement as given in traces)

Hi @akshita welcome to the forum! Please share here a reproducible example so that we can take a look.

As you can see, here I have used multicategory xaxis. The issue is that the xaxis label arrangement is not same as the one i have provided in xaxis array. The one i provide was sorted but here the arrangement of data is pretty random. Although i tried using 'categoryorder:‘category ascending’’ & alternatively i tried ‘categoryorder:‘array’’, specifying the ‘categoryarray’. But it didn’t work.
In need of a useful solution.
Note: I’m using javascript

for reference sample array
x: [[“2 AM”,“2 AM”,“2 AM”,“2 AM”,“2 AM”,“3 AM”,“3 AM”,“3 AM”,“3 AM”,“3 AM”,“3 AM”,“3 AM”,“3 AM”,“3 AM”,“3 AM”,“3 AM”,“3 AM”,“3 AM”,“3 AM”,“4 AM”,“4 AM”],[“02”,“03”,“06”,“57”,“58”,“00”,“01”,“04”,“25”,“30”,“32”,“39”,“40”,“42”,“46”,“52”,“56”,“57”,“58”,“01”,“02”]],
y: [1,2,3,1,1,1,2,2,12,1,1,2,5,1,2,4,5,6,7,1,2]

thank you. After some investigation, it seems that this kind of problem appears when the inner categories are not the same for all outer categories, see https://github.com/plotly/plotly.js/issues/3723. There is an open issue to make categoryarray work for multicategory axis which would solve this problem https://github.com/plotly/plotly.js/issues/3908. You can subscribe to this issue to get notified of further progress.

2 Likes