How to set a plotly categorical violinplot with specified xaxis order?
Here is an example code.
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',
)
)
Example of mapping functiopn and 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}
