-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Closed
Description
I am trying to make a faceted plot where I need to treat the x axis as categorical, even though it is an integer. On a single chart (that is not faceted), the following works:
fig.update_layout(xaxis_type='category')
However, on a faceted chart, only one of the facets is changed. I would think that updating the figure layout would iterate on all facets.
Is there an an alternate way to do this using one of the fig.for_each_*() methods? (as in for_each_xaxis() . I played around with it but could not seem to find a way to do it.
Using plotly 4.6.0 on windows
Thanks
import pandas as pd
import plotly.express as px
df = pd.DataFrame({
'x': [1, 2, 3, 5, 6],
'y1': [1, 2, 3, 4, 5],
'y2': [10, 11, 12, 13, 15]
}).melt('x')
bars = px.bar(
data_frame=df,
x = 'x',
y = 'value',
facet_col = 'variable'
)
bars.update_layout(xaxis_type='category')
bars.show()
sorenwacker
Metadata
Metadata
Assignees
Labels
No labels