在用Matplotlib作图时,我们经常会遇到x轴坐标过长,导致坐标重叠的情况。针对这一问题,我们可以将x轴坐标旋转45度。
import matplotlib.pyplot as plt
import seaborn as sns
sns.set(color_codes=True)
plt.bar(x, pvalue, align="center", color="c",
tick_label = label)
plt.xticks(rotation=45) #45为旋转的角度
plt.xlabel("cell name")
plt.ylabel("p value")
plt.savefig('result', dpi=400)
旋转前:

旋转后:

网友评论