【发布时间】:2020-11-09 06:02:24
【问题描述】:
我搜索了多个帖子,其中包含可能相关或不相关的不清楚的解决方案,并且尝试过但无法这样做。
我当前的绘图确实绘制了数字,但它没有显示年份的所有值,我希望它是一个整数。
我的 matplotlib 代码是:
import matplotlib.pyplot as plt
year, value = 0, 0.0
year = [1997,1998,1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2012,2013,2014, 2015, 2016]
value = [26242.5,27906.7,29192.7,30407.5,1564.9,2313.5,2989.4,3668.6,22082.6,29964.2,30481.6,35981.7,39597.6,38659.6, 34325.9,6913.5,35780.6,39111.5,37116.5,35385.5]
plt.plot(year, value)
plt.title('A - Value of apples vs Year')
plt.xlabel('Year')
plt.ylabel('Value of apples')
plt.grid(True)
plt.show()
【问题讨论】:
-
您需要设置刻度格式化程序matplotlib.org/3.1.1/gallery/ticks_and_spines/…
标签: python list matplotlib variables figsize