1

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)
Austin Jin
  • 141
  • 3
  • 11
  • 1
    Does this answer your question? [prevent scientific notation in matplotlib.pyplot](https://stackoverflow.com/questions/28371674/prevent-scientific-notation-in-matplotlib-pyplot) – Trenton McKinney Sep 08 '20 at 15:51

1 Answers1

1

You can use this command:

import matplotlib.ticker as ticker
axs[0].yaxis.set_major_formatter(ticker.FormatStrFormatter('%.2f'))
JohanC
  • 71,591
  • 8
  • 33
  • 66
gtomer
  • 5,643
  • 1
  • 10
  • 21