【发布时间】:2020-12-23 11:02:23
【问题描述】:
如何设置具有指定 xaxis 顺序的情节分类小提琴图?
这是一个示例代码。
ordered_x = df['target']
ordered_x = sorted(ordered_x, key=lambda x: mapping[x])
fig.add_trace(go.Violin(x=df['target'],
y=df[feature],
name='test',
side='positive',
)
)
functiopn 和 df['target'] 的映射示例。
df['target'] = ['a', 'this is a target', 'this is also a target']
mapping = {'a': 1, 'this is a target': 3, 'this is also a target': 2}
【问题讨论】:
-
你能分享你的映射功能吗?
-
这是一个帮助对xaxis进行排序的字典。我在上面添加了一个示例。