I am new to python and matplotlib and I am having hard times suppressing scientific notation in pyplot for a few hours now. I tried solutions recomended on prevent scientific notation in matplotlib.pyplot but none worked. I also tried solutions listed on https://code-examples.net/en/q/2677a94 and those did not work too. I am at loss. Please help.
I am using jupyter notebooks.
imported python libraries
import pandas as pd
import numpy as np
import requests
import zipfile
import io
import xlrd
%matplotlib inline
import matplotlib as mpl
import matplotlib.pyplot as plt
mpl.style.use('ggplot') # optional: for ggplot-like style
# check for latest version of Matplotlib
print ('Matplotlib version: ', mpl.__version__) # >= 2.0.0
# Matplot version: 3.1.0
When I create default line plot with code below I get le7 on y axis.
# Draw Line Plot for Imigration from all countries
# years columns after the ones with no data got removed
years = list(map(str, range(1998, 2014)))
# total is a dataframe
total = df_uk.loc['Column_Total', years] # passing in years 1998 - 2013
total.plot(kind='line')
plt.title('Immigration in UK')
plt.ylabel('Number of Immigrants')
plt.xlabel('Years')
plt.show()
If I try to suppress scientific notation with below i get NameError: name 'ax' is not defined
ax.ticklabel_format(useOffset=False, style='plain')
total.plot(kind='line')
plt.title('Immigration in UK')
plt.ylabel('Number of Immigrants')
plt.xlabel('Years')
plt.show()
Full error:
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-17-576bd02a7dac> in <module>
1 # Draw Line Plot for Imigration from all countries
2
----> 3 ax.ticklabel_format(useOffset=False, style='plain')
4 total.plot(kind='line')
5
NameError: name 'ax' is not defined
Please help.