matplotlib图标签之间的空间相同

时间:2020-07-24 11:25:44

标签: python matplotlib

我有不同的值,它们之间没有相同的空格,这是一个示例:

1     0.01027   0.00658   0.01341    0.02485    ...etc
2     0.00421   0.00350   0.00391    0.00456    ...etc
3     0.00419   0.00344   0.00351    0.00387    ...etc
4     0.00417   0.00342   0.00342    0.00359    ...etc
5     0.00414   0.00327   0.00336    0.00348    ...etc
6     0.00411   0.00302   0.00332    0.00340    ...etc
7     0.00404   0.00298   0.00328    0.00332    ...etc
8     0.00393   0.00296   0.00325    0.00324    ...etc
9     0.00391   0.00295   0.00322    0.00319    ...etc
10    0.00391   0.00294   0.00320    0.00316    ...etc
11    0.00391   0.00294   0.00317    0.00313    ...etc
12    0.00391   0.00293   0.00315    0.00311    ...etc
13    0.00391   0.00293   0.00312    0.00309    ...etc
14    0.00391   0.00293   0.00310    0.00308    ...etc
15    0.00391   0.00293   0.00308    0.00306    ...etc
16    0.00391   0.00293   0.00307    0.00305    ...etc
17    0.00391   0.00293   0.00305    0.00303    ...etc
18    0.00391   0.00292   0.00303    0.00302    ...etc
19    0.00391   0.00292   0.00302    0.00301    ...etc
20    0.00391   0.00292   0.00301    0.00300    ...etc 

当我通过以下方式将它们绘制在matplotlib中时:

plt.plot(COL_0, COL_1)
plt.plot(COL_0, COL_2)
plt.plot(COL_0, COL_3)
plt.plot(COL_0, COL_4)
...etc

我得到以下情节:

plot 1

我如何在刻度之间强制保持恒定的间隔(不考虑数值),以使绘图更清晰:

plot 2

谢谢!

1 个答案:

答案 0 :(得分:0)

如何限制要绘制的数字

ax.plot(df.index[5:], df.loc[6:,'32'], label='32')

如何将x轴的范围向右扩展

ax.set_xlim(−5, 20)
相关问题