2017-02-20 93 views
0

我想更改python中matplotlib中x轴的比例。我正在使用以下代码。如何更改matplotlib中的x轴

df.iloc[:,5:9].plot(kind="density",subplots=True,layout=(2,2),sharex=False) 

我想为所有的X轴有不同的X轴比例。我试过的是

fig=plt.figure(figsize=(15,15)) 
ax1=fig.add_subplot(2,2,1) 
ax2=fig.add_subplot(2,2,2) 
ax2=fig.add_subplot(2,2,3) 
ax2=fig.add_subplot(2,2,4) 

ax1.set_xticks(np.arrange(1,5000,500)) 
ax2.set_xticks(np.arrange(1,5000,500)) 
ax3.set_xticks(np.arrange(1,5000,500)) 
ax4.set_xticks(np.arrange(1,5000,500)) 

但是,当我运行这个我得到空的数字。

回答

0

您需要在绘图的轴上运行,而不是在某些新创建的空轴上运行。

axes = df.plot(kind="density",subplots=True,layout=(2,2),sharex=False) 
axes[0,0].set_xticks(...)