我希望在“图形”中的Y轴以及“和”列中的“范围”。
total_by_year.plot(kind='bar' ,x='year',y='sum',rot=0, legend=False)
plt.show()
DataFrame输出:
year sum
0 2010 42843534.38
1 2011 45349314.40
2 2012 35445927.76
3 2013 0.00
答案 0 :(得分:1)
您可以使用此:
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()
或者,如果您只需要科学计数法,请删除plt.yticks(y)
答案 1 :(得分:0)
我明白了。
因此,您确实要更改图形的轴格式。 也许您可以看到How do I change the format of the axis label in matplotlib Ask Question
或者您也可以这样做
total_by_year.plot(kind='bar' ,x='year',y='sum',rot=0, legend=False,yticks=total_by_year["sum"])
但是会很丑。因此,我还建议您捕获斧头并修改其格式。