Delete Frame Borders in matplotlib bar graph

Question:

I have the Following plot:

```forest = sk.ensemble.RandomForestRegressor(n_estimators=250,random_state=0)
   forest.fit(X, y)
   importances = forest.feature_importances_
   std = np.std([tree.feature_importances_ for tree in forest.estimators_],axis=0)
   indices = np.argsort(importances)[::-1]
   refclasscol=list(df.columns.values)
   impor_bars = pd.DataFrame({'Features':refclasscol[0:20],'importance':importances[0:20]})
   impor_bars = impor_bars.sort_values('importance',ascending=False).set_index('Features')
   plt.rcParams['figure.figsize'] = (10, 5)
   impor_bars.plot.bar()```

Which displays this : here

I want to remove borders and make something like this:here

Is it possible?

Asked By: kuljot

||

Answers:

Typically, people use

plt.axis(‘off’)

to get plots that look like this:

enter image description here

An alternative is adjusting alpha to have very faint borders

enter image description here

The rationale is that the left and bottom axis have the ticks and labels and thus carry information, while the top and right add no value. This style is inspired by the work of Edward Tufte, who recommends that, rather than repeatedly adding emphasis to important elements in a graphic, you apply de-emphasis to unimportant elements.

Answered By: James_SO
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.