默认移除坐标轴标签偏移
我看到这里有其他问题提到过
plt.gca().get_xaxis().get_major_formatter().set_useOffset(False)
这个方法可以用来去掉当前图表的坐标轴偏移,但有没有办法让这个设置默认生效呢?我在matplotlibrc文件里没有找到什么有用的内容。
2 个回答
16
在2013年,添加了一个叫做 axes.formatter.useoffset
的布尔参数到 matplotlibrc 文件中,这个参数可以用来关闭偏移量。
比如可以这样使用:
import matplotlib as mpl
mpl.rcParams['axes.formatter.useoffset'] = False
2
不,这个是做不到的。这个内容在 ticker.py
的源文件第353行已经定义好了:
def __init__(self, useOffset=True, useMathText=None, useLocale=None):
# useOffset allows plotting small data ranges with large offsets: for
# example: [1+1e-9,1+2e-9,1+3e-9] useMathText will render the offset
# and scientific notation in mathtext
self.set_useOffset(useOffset)
作为一个默认参数值。所以默认值是 True
。
当然,你可以修改源文件。