diff = [[10,20,30],[40,50,60],[70,80,90]]
comp = ["foo","bar","baz"]
fig,ax = plt.subplots()
for foo in range(0, len(diff)):
x = [diff[foo]]
name = comp
color = ['0.1', '0.2', '0.3']
label = ['1000000','1200000', '1400000']
y = zip(*x)
pos = np.arange(len(x))
width = 1. / (1 + len(x))
fig = plt.subplot(3,1,foo)
for idx, (serie, color,label) in enumerate(zip(y, color,label)):
ax.bar(pos + idx * width, serie, width, color=color,label=label)
fig = plt.gcf()
fig.set_size_inches(28.5,10.5)
ax.set_xticks(pos + 1.5*width)
plt.ylabel(name[foo])
ax.set_xticklabels(comp)
ax.legend()
plt.gray()
plt.savefig("file" + '.jpg', bbox_inches='tight', pad_inches=0.5,dpi=100)
plt.clf()
我想在图中添加foo bar 和 baz
的子图。但是,当我尝试使用上面的代码时,数据没有显示在图表上。有任何想法为什么?
Montage
来合并图像。 :)就像这样montage -geometry 500 image1 image2 [...] output
- pistalsubplots
:一次是在循环之前没有参数的情况下,这将创建一个只有一个轴的图形,但是在循环中你再次使用(3,1, ...)
调用它。你需要将第二次调用移到顶部,然后在三个轴中每个轴上绘制一次。 - askewchan