简体   繁体   中英

Turn off scientific notation and offset globally

I have been trying for several hours to globally turn off scientific notation and the offset in matplotlib. my attempt at a solution

import matplotlib  as mpl
import matplotlib.pyplot as plt

The documentation says:

set the rcParam axes.formatter.useoffset=False to turn it off globally, or set a different formatter.

mpl.rcParams.formatter.useoffset = False 

Of course this fails because there is no formatter for rcParam

mpl.ticker.FuncFormatter.__setattr__('set_scientific',False)

I am completely lost trying to do this. I have just switched from matlab. So I apologize if this is very basic

You need to change the setting in setting file, you can get the current setting file path by following code:

import matplotlib as mpl
print mpl.matplotlib_fname()

if the file is in mpl-data folder, then copy it to user setting folder by following code:

import shutil
shutil.copy(mpl.matplotlib_fname(), mpl.get_configdir())

then restart you python session and show the path again:

print mpl.matplotlib_fname()

edit this file:

axes.formatter.useoffset      : False 

Is you only want to disable this in one of your programm, you can set the setting before any plot:

mpl.rcParams["axes.formatter.useoffset"] = False

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM