默认情况下移除轴标签偏移

10

我已经阅读了这里提供的其他问题

plt.gca().get_xaxis().get_major_formatter().set_useOffset(False)

作为一种消除当前绘图轴偏移的方法,但是否有默认的方法可以实现这一点?我在matplotlibrc文件中没有看到任何有用的内容。

2个回答

15

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

例如像这样:

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

1
你能否添加一行代码,向我们这些matplotlib的新手展示如何使用它?谢谢!(类似于这个)。 - uhoh
3
@uhoh import matplotlib.pyplot as plt; plt.rcParams['axes.formatter.useoffset'] = False 同样可行。 - ImportanceOfBeingErnest
使用subplot2grid时无法工作,参数被忽略。 - misantroop

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

当然,您可以修改源代码。


3
这个答案是错误的,直接在原地编辑您的安装是一个极其糟糕的想法。 - tacaswell

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接