【发布时间】:2018-09-28 08:50:29
【问题描述】:
我正在尝试在条形图上绘制一条线。
这是我的数据框:
meh fiches ratio
2007 1412 1338 0.947592
2008 1356 1324 0.976401
2009 1394 1298 0.931133
2010 1352 1275 0.943047
2011 1398 1325 0.947783
2012 1261 1215 0.963521
2013 1144 845 0.738636
2014 1203 1167 0.970075
2015 1024 1004 0.980469
2016 1197 1180 0.985798
当我运行这两行时,我得到:
ax = graph[['meh', 'fiches']].plot(kind='bar', color=['#666666','#999999'])
graph[['ratio']].plot(kind='line',color='red', linestyle='-', secondary_y=True, ax=ax)
但是,如果我删除 kind='bar' 我会得到三行,如果我将 kind='line' 更改为 kind='bar' 我会得到三行...
【问题讨论】:
标签: python python-3.x pandas dataframe matplotlib