Home > Enterprise >  xaxes labels not displaying correctly
xaxes labels not displaying correctly

Time:02-28

I'm trying to create a histogram based on the following dataset.

dataset

I want independent x axes with labels, so I tried the following code:

fig = go.Figure()
fig = px.histogram( x=df["mun"], y=df["cust"], color=df["prod"], facet_col=df["pr"] )
fig.update_xaxes(matches=None, showticklabels=True)
fig.show()

As you can see the second plot does not show the labels for x. I don't understand why this is happening. How can I fix it?

graph

CodePudding user response:

I don't know why this is happening - it may be some bug in the categorical axis labels when plotly generates facet plots.

You can manually specify category_array=['D','E'] when you update the xaxes, which is admittedly a brittle workaround:

fig.update_xaxes(matches=None, showticklabels=True, categoryarray=['D','E'])

enter image description here

  • Related