调整Matplotlib中的轴

时间:2015-11-19 09:31:38

标签: python matplotlib graph axis imdb

使用Matplotlib创建图形时,我已将其编码为自动调整轴的大小,如下所示:

plt.axis([(int(yearofreleaselist[oldestfilm])-1), (int(yearofreleaselist[0]))+1, 0, (max(profits))+50000000])

但是,处理大数字时,利润只会显示一个带有各种速记参考的数字,如此示例图所示:

Example Graph

发布年份也没有正确绘制,但有些结果显示正确,如下所示:

As seen here

我想知道如何解决这个问题,以便数字始终正确显示。

1 个答案:

答案 0 :(得分:1)

您可以停用偏移量(see documentation

import numpy as np
import pylab as pl

years = np.arange(2011,2016,1)
profit = np.random.random(years.size)

pl.figure()
ax=pl.subplot(121)
pl.scatter(years, profit)
ax=pl.subplot(122)
pl.scatter(years, profit)
ax.get_xaxis().get_major_formatter().set_useOffset(False)

enter image description here

或者,为所有图形/轴设置它:

import matplotlib as mpl
mpl.rcParams['axes.formatter.useoffset'] = False