plotly.py icon indicating copy to clipboard operation
plotly.py copied to clipboard

PX doesn't force category orders on axes

Open nicolaskruchten opened this issue 4 years ago • 1 comments

This causes ordering issues like this:

import plotly.express as px
import pandas as pd

df = pd.DataFrame(dict(
    x=['a','b','c','d'],
    y=[1,2,3,4],
    z=['p','q','p','q']
))

px.bar(df, x="x", y="y", color="z")

newplot (1)

nicolaskruchten avatar Jul 07 '21 13:07 nicolaskruchten

The workaround right now is to do category_orders=dict(x=df.z.unique()) but ideally this would be done internally.

nicolaskruchten avatar Jul 07 '21 13:07 nicolaskruchten