I have some code that is plotting the importance of variables from a random forest.
I can't seem to shift the plot over so that the x axis begins at zero.
The gap here along the x axis between -0.01 and 0.00 is very large and I'd like to get rid of it:
I included this line in my code:
plt.xlim([-0.5, 0.07])
and it didn't help:
Thanks for looking at this.
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()