This fix would be fairly simple, I think, something like this, where series is whatever's being rendered to the xaxis (or y, or legend, etc)
if isinstance(series.dtype, pd.CategoricalDtype) and series.cat.ordered:
fig.update_xaxes(
categoryorder="array",
categoryarray=series.cat.categories,
)
Plotly version: 5.9.0.
I've noticed a number of bugs relating to pd.Categorical and pd.PeriodIndex, are there plans for better Pandas support, or is that not an area of focus?
I am plotting a chart with a
pd.Categorical
series on the x-axis. The category has a sort defined.Expected behaviour: the axis is sorted as per the underlying category definition Actual behaviour: the axis is sorted by the order of the data
This fix would be fairly simple, I think, something like this, where
series
is whatever's being rendered to the xaxis (or y, or legend, etc)Plotly version:
5.9.0
.I've noticed a number of bugs relating to
pd.Categorical
andpd.PeriodIndex
, are there plans for better Pandas support, or is that not an area of focus?