简体   繁体   中英

turn off scientific notation for matplotlib

I want to turn off the scientific notation for both graphs on the y-axis. I added ticklabel_format but it does not work. how to let two y-axis both use plain notations?

import pandas as pd
import datetime as dt
import pandas_datareader as web
import matplotlib.pyplot as plt
from matplotlib import style
style.use('dark_background')

prev=3000
end=dt.datetime.today().date()
st=end-pd.to_timedelta(prev,unit='d')

init_jobless=web.DataReader('ICSA','fred',st,end)
cont_jobless=web.DataReader('CCSA','fred',st,end)

fig, axs = plt.subplots(2,sharex=True)
axs[0].plot(init_jobless,label='US Initial Jobless Claims')
axs[0].set_title('US Initial Jobless Claims')
axs[1].plot(cont_jobless)
axs[1].set_title('US Continued Jobless Claims')
axs.ticklabel_format(axis='y',style='plain')
plt.show()
print(init_jobless,cont_jobless)

你可以使用这个命令:

axs[0].yaxis.set_major_formatter(ticker.FormatStrFormatter('%.2f'))

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