【发布时间】:2019-04-29 14:25:54
【问题描述】:
我正在尝试使用 matplotlib 获取条形图。图中只有 2 个条形,但它们之间的空间非常大。我试图减少和增加宽度,但它只是改变了条形的宽度。
def evaluate_bar_graph(coherences, indices):
assert len(coherences) == len(indices)
n = len(coherences)
x = np.arange(n)
plt.bar(x, coherences, width=0.1, tick_label=indices, align='center')
plt.xlabel('Models')
plt.ylabel('Coherence Value')
plt.show()
【问题讨论】:
-
@Goyo 没有其他解决方案吗?
-
@Sheldore 我不要求工作答案。我在问有什么办法可以减少空间
-
“我试图减少和增加宽度,但它只是改变了条形宽度”是什么意思,这不正是您想要做的吗?让
x=[0,1]和coherences=[1,2],一旦你到达width=1,条就会“接触”;如果x=[0,2],它们之间将有“1”! -
width 只是改变了条形宽度。如您所见,我想减少条形之间的空间。不要增加条形宽度
标签: python python-3.x matplotlib