首页 > 解决方案 > 在 matplotlib 条形图中删除框架边框

问题描述

我有以下情节:

```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()```

显示这个:here

我想删除边框并做这样的事情:这里

是否可以?

标签: pythonmatplotlib

解决方案


通常,人们使用

plt.axis('关闭')

得到看起来像这样的图:

在此处输入图像描述

另一种方法是调整 alpha 以具有非常微弱的边框

在此处输入图像描述


推荐阅读