bar不重叠 matlab,在matplotlib中,如何避免多条形图中的条形图重叠

我试图用可变的x值绘制多个条形图。我的情节是这样的

74089f9d4d05a2786b583cdb7e39a122.png

如您所见,StartFFT_Gflops中的条与x轴上的下一个记号重叠。有没有什么方法可以增加刻度线之间的间距,使条形图不重叠?在

我用下面的代码来绘制def plot_bars(hpcc_data, datapoints):

fig, ax = plt.subplots()

ind = np.arange(len(datapoints)) # array of x-ticks = no of datapoints to plot

offset = 0 # offset distance between bars

bar_legends = list()

bar_obj = list()

width = 0.35

colors = ['b', 'g', 'r', 'c', 'm', 'y', 'k'] # hopefully we won't need more than this

color_idx = 0

for host in hpcc_data:

host_data = hpcc_data[host]

vals = list()

for dp in datapoints:

vals.append(host_data[dp])

bar = ax.bar(ind + offset, vals, width, color=colors[color_idx])

bar_legends.append(host)

bar_obj.append(bar[0])

color_idx += 1

offset += width #for the next host

ax.legend(bar_obj, bar_legends)

ax.set_ylabel('Gflops')

ax.set_title('Scores of hpcc benchmark')

ax.set_xticks(ind + (len(hpcc_data.keys())/2)*width) #approx center the xticks

ax.set_xticklabels(datapoints)

plt.show()

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值