-2

I am trying to change my y axis scale.Indeed, Python puts my numbers into scientific notation. I want to stay with my original numbers.

This is my code:

Data = [['01',  float(18535404.0)],['02', float(3460047.0)], 
        ['03', float(3924627.0)],['04',float(3377404.0)],
        ['05',float(4006194.0)],['06',float(11077562.0)],
        ['07',float(2097105.0)],['08',float(2042300.0)],
        ['09',float(899693.0)],['10',float(7598384.0)],
        ['11',float(998367.0)]] 
# Create the pandas DataFrame
DataFrame3 = pd.DataFrame(Data, columns=['Month', 'Sum'])
# print dataframe.
DataFrame3
plt.bar(DataFrame3['Month'],DataFrame3 ['Sum'] ,color=(0.2, 0.4, 0.6, 0.6))

I would like these numbers on my y axis:

18535404.0,3460047.0,3924627.0;....
Dr. Abrar
  • 327
  • 2
  • 5
  • 17

2 Answers2

1

Matplotlib has a function called ticklabel_format that can be used for this.

Adding the following line (before plt.show()) will remove the scientific notation.

plt.ticklabel_format(style='plain', axis='y')

For more info, please refer the documentation.

0

In python, floating numbers are truncated to lower decimals, and then parsed. If you want to exactly use the numbers as they are, try converting them to string.

str(num)

Your code will become:

Data = [['01', str(18535404.0)], ['02', str(3460047.0)], ['03', str(3924627.0)],['04',str(3377404.0)],['05',str(4006194.0)],['06',str(11077562.0)], ['07',str(2097105.0)],['08',str(2042300.0)],['09',str(899693.0)],['10',str(7598384.0)],['11',str(998367.0)]]


DataFrame3 = pd.DataFrame(Data, columns=['Month', 'Sum'])


plt.bar(DataFrame3['Month'],DataFrame3 ['Sum'] ,color=(0.2, 0.4, 0.6, 0.6))