Multicategory for y-axis?

Hi all!
I’m new writing in the forum, not reading, thank you all for sharing your knowledge. I’ve joined to ask if there is any possibility to use multicartegory in the y-axis. Or maybe there are plans to make this possible in near future? It would be very interesting,

Thank you all.

Hi @Aire welcome to the community!

If you can describe what you are trying to achieve that would help others answer your question. What type of chart are you working with? Any screenshots or code snippets is highly encouraged.

Also have you checked this section of the docs, this might be what you are looking for - Categorical axes in Python

Hi @atharvakatre , thank you four your response. Sure, I should have gave those details in my question! I’ve read that documentation and I’ve already used it in some charts like this:
categ_plot1
Now I also need it to do something like:


Is it possible? I mean multicategory for y-axis, not stacking bars… I have not succeeded in doing it.

Thank you!

@Aire,

You can use multicategory for both x and y-axis, however for y-axis you may have to change the orientation of the bars to be horizontal. See the use of orientation='h' in the below example:

import plotly.graph_objects as go

fig = go.Figure()

fig.add_trace(go.Bar(
  x = [2, 3, 1, 5],
  y = [['First', 'First', 'Second', 'Second'],
       ["A", "B", "A", "B"]],
  name = "Adults",
  orientation='h'
))

fig.add_trace(go.Bar(
  x = [8, 3, 6, 5],
  y = [['First', 'First', 'Second', 'Second'],
       ["A", "B", "A", "B"]],
  name = "Children",
  orientation='h'
))

fig.update_layout(title_text="Multi-category axis")

fig.show()

And if you’d like the bars to be stacked, set barmode='stack' in the update_layout:

1 Like

Thank you, I misused the property! Now it works.

1 Like