使用时如何更改Xaxis上分类值的顺序seaborn.FacetGrid?

2024-04-25 13:25:11 发布

您现在位置:Python中文网/ 问答频道 /正文

我有以下代码:

g = sns.FacetGrid(correct_data, hue="congruency", col="PP", row="cue", height=4, ylim=(.4, .9))
g.map(sns.pointplot, "pattern", "RT")

这允许我为每个参与者(PP)和提示(cue)创建一个线图,为每个一致性级别显示单独的线。每一行显示了模式(X轴)和反应时间(Y轴上的RT)之间的关系。我想反转X轴上的分类值的顺序,我该怎么做? “pattern”变量有两个级别,但我喜欢反转它的默认显示顺序。你知道吗

谢谢你。你知道吗


Tags: 代码data顺序col级别huepprow
1条回答
网友
1楼 · 发布于 2024-04-25 13:25:11

可以在对g.map()的调用中将^{} parameter(以及hue_order=)传递给sns.pointplot(),以选择分类变量的顺序

att = sns.load_dataset("attention")
g = sns.FacetGrid(att, col="subject", col_wrap=5, height=1.5)
g = g.map(sns.pointplot, "solutions", "score", order=[3,1,2])

enter image description here

相关问题 更多 >