代码
import pygal
this_bar = pygal.Bar()
years = ['1991', '1992', '1993', '1994', '1995', '1996', '1997', '1998',
'1999', '2000', '2001', '2002', '2003', '2004',
'2005', '2006', '2007', '2008', '2009', '2010', '2011', '2012',
'2013', '2014', '2015', '2016', '2017', '2018']
salaries = [2877, 3402, 4523, 6540, 8144, 9579, 11019, 12285, 13778,
15726, 18092, 20728, 24045, 28348, 32808, 36097,
39867, 44715, 48444, 50415, 56061, 62677, 69521, 77560, 85038,
92477, 101599, 94258]
this_bar.x_labels = [x[-2:] for x in years]
this_bar.add('month', values=[x / 12 for x in salaries])
this_bar.title = 'BeiJing avg salary'
this_bar.render_in_browser()
from matplotlib import pyplot as plt
plt.figure(dpi=200)
p1 = plt.bar(years, [x / 12 for x in salaries], width=0.35)
plt.title("beijing avg salaries")
plt.xlabel("year")
plt.ylabel("salaries by month")
plt.tick_params(axis='x', labelsize=9, rotation=50)
plt.savefig('BeiJing avg salary.jpg', dpi=200, bbox_inches='tight')
plt.show()

数据来源
- http://rsj.beijing.gov.cn/xxgk/gsgg/201905/t20190530_82753.html
- http://www.beijing.gov.cn/zfxxgk/110037/ndsj53/2018-05/31/content_43bf77b4bf974e3bb2499b218029458e.shtml
- http://www.beijing.gov.cn/zfxxgk/110037/tjxx53/2017-05/31/content_816968.shtml
- http://www.beijing.gov.cn/zfxxgk/110037/ndsj53/2016-06/06/content_705752.shtml
- http://www.beijing.gov.cn/zfxxgk/110037/tjxx53/2015-06/10/content_585516.shtml
- http://www.beijing.gov.cn/zfxxgk/110037/tjxx53/2014-06/10/content_480666.shtml
- http://www.beijing.gov.cn/zfxxgk/110037/tjxx53/2013-06/28/content_395626.shtml
- http://www.beijing.gov.cn/zfxxgk/110037/tjxx53/2012-07/17/content_312483.shtml
- http://www.beijing.gov.cn/zfxxgk/110037/tjxx53/2011-12/28/content_288796.shtml
- http://invest.beijing.gov.cn/gb/showArticle.do?articleId=82818