是否可以使用seaborn
更改regplot中x刻度的“名称”?
我有一个包含分类变量的数据集(dataset
),我正在尝试对此进行线性回归:
import seaborn as sns
fig = sns.regplot(x='Cond_L', y='RT', data=dataset, x_estimator=np.mean)
Cond_L
似乎是一个数字变量,但它是具有以下可能值的绝对变量:1
,2
,3
,4
。
但是,绘制时,我的x轴从1变到4,但以0.5为步幅,而不是1。
所以我的问题是(1)如何只有四个刻度线; (2)如何将数字更改为文本,即Cond1
,Cond2
,Cond3
,Cond4
?
答案 0 :(得分:0)
我设法找到了解决方案:
ax.set(xticks=np.arange(1, 5, 1)) #limit the number of ticks to 4
ax.set_xticklabels(['Cond1','Cond2','Cond3', "Cond4"]) #rename ticks