[英]How to control scientific notation in matplotlib?
這是我要繪制的數據框:
my_dic = {'stats': {'apr': 23083904,
'may': 16786816,
'june': 26197936,
}}
my_df = pd.DataFrame(my_dic)
my_df.head()
這是我的繪圖方式:
ax = my_df['stats'].plot(kind='bar', legend=False)
ax.set_xlabel("Month", fontsize=12)
ax.set_ylabel("Stats", fontsize=12)
ax.ticklabel_format(useOffset=False) #AttributeError: This method only works with the ScalarFormatter.
plt.show()
劇情:
我想控制科學計數法。 我試圖按照其他問題plt.ticklabel_format(useOffset=False)
建議通過此行來抑制它,但是我得到了此錯誤AttributeError: This method only works with the ScalarFormatter
。 理想情況下,我想以(mln)顯示數據。
由於您已經在使用pandas
import matplotlib.pyplot as plt
my_df.plot(kind='bar')
plt.ticklabel_format(style='plain', axis='y')
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.