需要更改我的图表matplotlib中的轴之一的速度

问题描述

绘图的新手需要帮助 有我正在研究的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 (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...