美文网首页
Matplotlib如何解决X轴坐标过密

Matplotlib如何解决X轴坐标过密

作者: 坐看云起时zym | 来源:发表于2019-07-16 23:40 被阅读0次

在用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)

旋转前:


before.png

旋转后:


post.png

相关文章

网友评论

      本文标题:Matplotlib如何解决X轴坐标过密

      本文链接:https://www.haomeiwen.com/subject/wzvxlctx.html