如何从 Matplotlib 中的分组条形图中删除空格。我的图表尺寸为 3.5x4 英寸。
fig= plt.figure(figsize=(3.5,4),dpi=600)
这是我的代码
index = np.arange(n_groups)
bar_width = 0.05
rects1 = plt.bar(index, SeriesA_1, bar_width)
rects2 = plt.bar(index + 0.05, SeriesA_2, bar_width)
rects3 = plt.bar(index + 0.10, SeriesA_3, bar_width)
rects4 = plt.bar(index + 0.15, SeriesB_1, bar_width)
rects5 = plt.bar(index + 0.20, SeriesB_2, bar_width)
rects6 = plt.bar(index + 0.25, SeriesB_3, bar_width)
plt.ylim((0,14))
请您参考如下方法:
由于您的
bar_width是 0.05,并且您每组绘制 6 个项目,因此每组用掉 0.3。您在
index处绘图,即每组跳 1 个。
尝试使用
plt(0.3 * index + ...
在每个地方,而不是当前
plt(index + ...
你现在有。
