<分区>
我正在尝试绘制 n 个直方图并将它们并排显示在一起(不在同一个直方图中。
我试过这段代码:
for r in range(1, n):
plt.hist(combined['apple{} tomato'.format(n)], bins = bin, alpha=0.5, color='#0bf9ea')
plt.hist(combined['apple{} potato'.format(n)], bins = bin, alpha=0.5, color='#ff7fa7')
plt.show()
当我输入这段代码时,它会显示直方图 1,然后当我关闭图形时,会出现直方图 2,依此类推,直到直方图 n。
for r in range(1, n):
plt.hist(combined['apple{} tomato'.format(n)], bins = bin, alpha=0.5, color='#0bf9ea')
plt.hist(combined['apple{} potato'.format(n)], bins = bin, alpha=0.5, color='#ff7fa7')
plt.show()
但是,当我尝试这段代码时,它显示了一个直方图,所有直方图合而为一。
有没有办法在一个窗口中单独显示所有 n 个不同的直方图?
谢谢:D