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

问题描述 投票:0回答:1

我有以下代码:

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”变量有两个级别,但是我想颠倒默认的显示顺序。

谢谢。

python seaborn axis-labels facet-grid
1个回答
0
投票

您可以在调用order= parameter的过程中将order=(以及hue_order=)传递给sns.pointplot()以选择分类变量的顺序

g.map()

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])

© www.soinside.com 2019 - 2024. All rights reserved.