Ali Rahimpour
Ali Rahimpour

Reputation: 11

How to change the order of categorical x-axis in interaction plot in python?

So I am generating the interaction plot by using statsmodels package. Here in the figure below, you can see my current result.
I would like to have first "Block" and second "Alternating" in my x-axis. I was wondering how to make this change? Here is my code:

from statsmodels.graphics.factorplots import interaction_plot
import matplotlib.pyplot as plt
fig = interaction_plot(x=d['Group'], trace=d['Condition'], response=d['Asynch'],
    colors=['blue','yellow','green','gray'])
plt.rc("figure")
plt.rc('xtick', labelsize=24) 
plt.rc('ytick', labelsize=24)
plt.xlabel('Condition', fontsize=28)
plt.ylabel('IRI (ms)', fontsize=28)
sns.set(font_scale = 1.4)
plt. legend(loc='upper center', prop={'size': 24})
plt.legend(loc='upper right')
plt.ylabel("Asynchrony (ms)")
plt.show()
# plt.savefig('interaction.png', dpi=300)
fig.savefig('interaction.png', dpi=600)

and here is the result:
My interaction plot

Upvotes: 1

Views: 610

Answers (0)

Related Questions