Boxplot and striplot don't align with the axis

31 views Asked by At

i have difficulty to solve this problem, my plot doesnt align with my box which are not centered with the axis, and i don't know why despite trying all the parameters.

Here my code :

plt.figure()
   ax =sns.boxplot(x="Station", y="MV (kg/m3)", data=DonneesLVL,hue='Sylviculture', order=[11,6,10,5,1], width=1)
sns.stripplot(x="Station", y="MV (kg/m3)", data=DonneesLVL,hue='Sylviculture', ax=ax, dodge = True, jitter=True,order=[11,6,10,5,1])
handles, labels = ax.get_legend_handles_labels()
l = plt.legend(handles[0:6], labels[0:6], fontsize=10)
plt.ylabel('Masse volumique (kg/m3)')
plt.savefig("MVLVL.png",dpi=300,bbox_inches="tight")
plt.show()

The result is :

enter image description here

I tried to test different parameters, but didnt work here

1

There are 1 answers

0
Madhu Sri On

You can try changing the dodge value to set it as False in sns.stripplot. It can be changed as:

sns.stripplot(x="Station", y="MV (kg/m3)", data=DonneesLVL, hue='Sylviculture', ax=ax, dodge=False, jitter=True, order=order)