Plotly express 散点图不允许对分类标签进行排序

Ploltly express scatterplot does not allow for sorting categorical labels

似乎设置 x 轴的类别顺序会使 px.scatter 使用边际图时图形崩溃

import pandas as pd
import plotly.express as px # plotly 4.9.0

df = pd.DataFrame({'x':['c', 'a', 'b'], 'y':[1,2,1]})
fig = px.scatter(df, x='x', y='y', marginal_y='box')
fig.update_xaxes(categoryorder='category ascending') # Line x
fig.show(renderer='browser')
# Only works, if line x is removed, or when parameter marginal_y='box' is removed

这是一个错误还是我遗漏了什么?

尝试更新布局

import pandas as pd
import plotly.express as px # plotly 4.9.0

df = pd.DataFrame({'x':['c', 'a', 'b'], 'y':[1,2,1]})
fig = px.scatter(df, x='x', y='y', marginal_y='box')
fig.update_layout(xaxis=dict(type='category',categoryorder='category ascending'))
fig.show()