我试图在python中制作堆积条形图,但最终产品似乎缺少条形图。我相信第一个酒吧应该总共36左右,但事实并非如此。我不确定我做错了什么。这是我的代码的简化版本:
import numpy as np
import matplotlib.pyplot as plt
a = [7, 12, 10, 12, 11]
b = [1, 5, 3, 5, 4]
c = [0, 2, 0, 2, 0]
d = [1, 5, 0, 0, 0]
e = [1, 2, 0, 1, 0]
f = [2, 10, 1, 1, 0]
g = [4, 4, 0, 1, 0]
h = [5, 4, 0, 1, 0]
i = [4, 10, 0, 2, 1]
j = [1, 1, 0, 3, 0]
k = [7, 5, 3, 15, 7]
l = [3, 7, 4, 4, 1]
ind = np.arange(5)
x = plt.bar(ind, a, color=(np.random.random([1.0]),np.random.random([1.0]),np.random.random([1.0])))
x = plt.bar(ind, b, color=(np.random.random([1.0]),np.random.random([1.0]),np.random.random([1.0])), bottom=a)
x = plt.bar(ind, c, color=(np.random.random([1.0]),np.random.random([1.0]),np.random.random([1.0])), bottom=a)
x = plt.bar(ind, d, color=(np.random.random([1.0]),np.random.random([1.0]),np.random.random([1.0])), bottom=a)
x = plt.bar(ind, e, color=(np.random.random([1.0]),np.random.random([1.0]),np.random.random([1.0])), bottom=a)
x = plt.bar(ind, f, color=(np.random.random([1.0]),np.random.random([1.0]),np.random.random([1.0])), bottom=a)
x = plt.bar(ind, g, color=(np.random.random([1.0]),np.random.random([1.0]),np.random.random([1.0])), bottom=a)
x = plt.bar(ind, h, color=(np.random.random([1.0]),np.random.random([1.0]),np.random.random([1.0])), bottom=a)
x = plt.bar(ind, i, color=(np.random.random([1.0]),np.random.random([1.0]),np.random.random([1.0])), bottom=a)
x = plt.bar(ind, j, color=(np.random.random([1.0]),np.random.random([1.0]),np.random.random([1.0])), bottom=a)
x = plt.bar(ind, k, color=(np.random.random([1.0]),np.random.random([1.0]),np.random.random([1.0])), bottom=a)
x = plt.bar(ind, l, color=(np.random.random([1.0]),np.random.random([1.0]),np.random.random([1.0])), bottom=a)
plt.show()