问题描述
绘图的新手需要帮助 有我正在研究的DATAFRAME。试图将我的左侧y_axis上的速度更改为5,而不是10,但是我想'Axessubplot'对象没有属性'yticks',所以我不能使用
ax.yticks(np.arange(0,max(GDP['GDP'])+5,5))
这是我的代码(绘图部分)
fig = plt.figure() # Create matplotlib figure
ax = fig.add_subplot(111) # Create matplotlib axes
ax2 = ax.twinx() # Create another axes that shares the same x-axis as ax.
width = 0.7
newdf.GDP.plot(kind='bar',color='#8D99FB',ax=ax,width=width)
newdf.Unemployment.plot(kind='line',color='red',ax=ax2)
ax.set_ylabel('GDP over The years in billions of dollars')
#ax.yticks(np.arange(0,5))
ax2.set_ylabel('Percentage of Unemployment/total Population')
ax.set_xticklabels(newdf.Year.tolist())
ax.set_xlim(-width,len(newdf.Year.tolist()))
plt.title('GDP over The years in billions of dollars')
'''
ax.yticks(np.arange(0,5))
'''
plt.show()
谢谢
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)