Reputation: 333
I want the Y-axis in the Graph with the Range in the Sum column.
total_by_year.plot(kind='bar' ,x='year',y='sum',rot=0, legend=False)
plt.show()
DataFrame output:
year sum
0 2010 42843534.38
1 2011 45349314.40
2 2012 35445927.76
3 2013 0.00
below is the Graph i am getting:
Upvotes: 0
Views: 947
Reputation: 12417
You can use this:
import matplotlib.pyplot as plt
import matplotlib
y = total_by_year['sum']
ax = total_by_year.plot(kind='bar' ,x='year',y='sum',rot=0, legend=False)
ax.yaxis.set_major_formatter(matplotlib.ticker.FormatStrFormatter("%.2f"))
plt.yticks(y)
plt.show()
Or if you want just the scientific notation, remove plt.yticks(y)
Upvotes: 1
Reputation: 675
I see.
So exactly you want to change the axis format of the graph. Maybe you could see How do I change the format of the axis label in matplotlib Ask Question
Or you could also do like that
total_by_year.plot(kind='bar' ,x='year',y='sum',rot=0, legend=False,yticks=total_by_year["sum"])
but it will be ugly. So I also recommend that you should capture the ax and revise the format of its.
Upvotes: 0