matplotlib默认删除轴标签偏移量

8 python matplotlib

我在这里提供了其他问题

plt.gca().get_xaxis().get_major_formatter().set_useOffset(False)
Run Code Online (Sandbox Code Playgroud)

作为一种消除当前图上轴偏移的方法,但默认情况下有没有办法做到这一点?我在matplotlibrc文件中看不到任何看似有用的内容.

Chr*_*oph 11

2013axes.formatter.useoffset年,添加了一个名为boolean matplotlibrc的参数,可以关闭偏移量.

例如这样:

import matplotlib as mpl
mpl.rcParams['axes.formatter.useoffset'] = False
Run Code Online (Sandbox Code Playgroud)

  • @uhoh` import matplotlib.pyplot作为plt; plt.rcParams ['axes.formatter.useoffset'] = False`同样可行. (3认同)

CT *_*Zhu 2

不,没有办法做到这一点.它在第ticker.py353行的源文件中定义:

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)
Run Code Online (Sandbox Code Playgroud)

作为默认参数值.所以默认是True.

当然,您可以修改源.

  • 这个答案是错误的,就地编辑安装是一个非常糟糕的主意。 (3认同)