I’m having difficulty finding the solution, ‘etienne’, Since it’s not an open issue any longer on Github; https://github.com/plotly/plotly.js/pull/510
import plotly
import plotly.graph_objs
trace1_df =df[df['col1']=='blue'].sort_values(by='bins')
trace1 = plotly.graph_objs.Bar(
x=["(0, 5]","(5, 10]","(10, 15]","(15, 20]","(20, 25]","(25,35]","(35, 45]","(45, 55]","(55, 65]","(65, 75]","(75, 90]","(90, 105]","(105, 120]","(120, 150]","(150, 200]"],
y=trace1_df['num1'].tolist(),
name='blue'
)
trace2_df =df[df['col1']=='red'].sort_values(by='bins')
trace2 = plotly.graph_objs.Bar(
x=trace2_df['cat1'].tolist(),\
y=trace2_df['num1'].tolist(),
name='red'
)
data=[trace1,trace2]
layout = plotly.graph_objs.Layout(barmode='group')
fig = plotly.graph_objs.Figure(data=data,layout=layout)
plotly.offline.plot(fig)
I am trying to set the categorical x axis for all trace(s) on the Total Bar plot, by using the static list for the ‘trace1’. Yet, this is giving me an extra duplicate bin at the far right of my x axis. Ideally, I’d like to not hardcode the ‘x=…’. Is there a Python fix for the xaxis category order issue for Multiple Group Vertical Bar Charts?