11

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()
user977828
  • 7,259
  • 16
  • 66
  • 117
  • What do you mean with avoid values with 1e7? If you mean you do not want to see 1e7 at the y-axis, divide your data by 1e7. – oschoudhury May 06 '14 at 09:43
  • 1e7 is gone now, but now I have on the y-axis 0.0 to 2.5 which does not represent values in DataFrame. How is it possible to get values which represent more the DataFrame values? – user977828 May 06 '14 at 09:50
  • possible duplicate of [How to prevent numbers being changed to exponential form in Python matplotlib figure](http://stackoverflow.com/questions/14711655/how-to-prevent-numbers-being-changed-to-exponential-form-in-python-matplotlib-fi) – tacaswell May 06 '14 at 17:18

1 Answers1

13

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.

Holger
  • 2,125
  • 2
  • 19
  • 30