【发布时间】:2020-09-07 08:26:17
【问题描述】:
我正在使用 matplotlib 绘制水平图。我想添加网格并更改绘图的大小以避免标签重叠。我的代码如下所示:
baseline = [0.5745,0.5282,0.4923,0.5077,0.5487,0.5385,0.5231]
low = [0.2653,0.3878,0.3673,0.5510,0.2245,0.5714,0.3265]
high = [0.5102,0.5102,0.3673,0.3877,0.5306,0.4286,0.49]
index = ['Bagging','Decision tree','Gussian Naive Bayes','Logistic regression','Random forest','SVM','k-NN']
df = pd.DataFrame({'Baseline': baseline,'ttd lower than median': low,'ttd higher than median': high}, index=index)
plt.figure(figsize = (6,12))
ax.yaxis.grid(color='gray', linestyle='dashed')
ax = df.plot.barh()
结果图如下所示:
但是,它没有显示网格,并且“plt.figure(figsize = (6,12))”似乎不起作用。我怎样才能解决这个问题?提前致谢!
【问题讨论】:
标签: python matplotlib