【发布时间】:2017-06-22 05:18:32
【问题描述】:
我有一个barh 条形图,图中只有两个条形,但是在绘制它们时,它们相距很远:
import numpy as np
import matplotlib.pyplot as plt
labels = ('Out', 'In')
bar_values = [5, 10]
num_items = len(labels)
width = 0.25
ind = np.arange(num_items)
bar_width = 0.1
fig = plt.figure()
ax = fig.add_subplot(111)
barlist = ax.barh(ind,
bar_values,
bar_width,
align='edge',
color='green')
barlist[0].set_color('mediumseagreen')
barlist[1].set_color('orangered')
ax.set_yticks(ind)
ax.set_yticklabels(labels)
ax.invert_yaxis() # labels read top-to-bottom
ax.set_xlabel('Total')
plt.show()
有没有办法让这些条更靠近?我已经尝试指定图形的大小,但这只会减小整体大小,对间隙大小没有影响...
【问题讨论】:
标签: python matplotlib