Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to avoid axis values with 1e7 in pandas and matplotlib

Using the code below it produce a plot where y-axis is 0.0 to 2.5 1e7. How is it possible to avoid values with 1e7?

    import pandas as pd
    import matplotlib.pyplot as plt
    a = {'Test1': {1: 21867186, 4: 20145576, 10: 18018537},
         'Test2': {1: 23256313, 4: 21668216, 10: 19795367}}

    d = pd.DataFrame(a).T
    #print d

    f = plt.figure()

    plt.title('Title here!', color='black')
    d.plot(kind='bar', ax=f.gca())
    plt.show()
like image 435
user977828 Avatar asked May 06 '14 09:05

user977828


1 Answers

Use ticklabel_format(style = 'plain') as in the following example.

import pandas as pd
import matplotlib.pyplot as plt
a = {'Test1': {1: 21867186, 4: 20145576, 10: 18018537},
     'Test2': {1: 23256313, 4: 21668216, 10: 19795367}}

d = pd.DataFrame(a).T
#print d

f = plt.figure()

plt.ticklabel_format(style = 'plain')

plt.title('Title here!', color='black')
d.plot(kind='bar', ax=f.gca())
plt.show()

I hope this is what you meant.

like image 182
Holger Avatar answered Oct 25 '22 18:10

Holger