Search code examples
pythonmatplotlibx-axis

Remove axis label offset by default


I've read other questions here offering

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

as a way to remove axis offsets on the current plot, but is there any way to do this by default? I don't see anything in the matplotlibrc file that seems helpful.


Solution

  • No, there is no way to do it. It is defined in the source file of ticker.py, line 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)
    

    as a default parameter values. So the default is True.

    You can modify the source, of course.