2017-09-09 66 views
0

我有一些代碼是繪製隨機森林中變量的重要性。在matplotlib中將x軸置於0

我似乎無法改變情節,使x軸從零開始。

沿-0.01和0.00之間的x軸這裏的差距是非常大的,我想擺脫它:

enter image description here

我包括這條線在我的代碼:

plt.xlim([-0.5, 0.07])並沒有幫助:

enter image description here

感謝您看這個。

from pylab import rcParams 
rcParams['figure.figsize'] = 5, 10 

importances = rf.feature_importances_ 
std = np.std([tree.feature_importances_ for tree in rf.estimators_], 
      axis=0) 
indices = np.argsort(importances) 

list_of_labs = range(0,35) 

plt.title("Feature importances") 

plt.barh(range(X.shape[1]), importances[indices], 
     color="r", xerr=std[indices], align="center") 

plt.yticks(range(X.shape[1]), list_of_labs) 

plt.ylim([-0.5, X.shape[1]]) 

plt.show() 
+0

Errr ......你知道'xlim'但似乎不能夠選擇的限制......我的意思是,你有沒有試過'plt.xlim([0,0.07])'? – ForceBru

回答

0

您可以只設置起點

plt.xlim(xmin=0)