import numpy as np import matplotlib.pyplot as plt N = 5 ind = np.arange(N) # the x locations for the groups width = 0.35 # the width of the bars # Shenanigans because I'm using generated data cumulative = np.zeros(N) legends = () for i in range(0,10): sigma = np.random.rand()*10 + 10 mu = np.random.rand()*10 + 50 means = np.abs(sigma*np.random.randn(N) + mu) Stds = np.abs(np.random.rand(N)*2 + 2) p = plt.bar(ind, means, width, yerr=Stds, bottom=cumulative) cumulative = cumulative + means legends = legends + (p[0],) plt.ylabel('Scores') plt.title('Scores by group and treatment') plt.xticks(ind, ('G1', 'G2', 'G3', 'G4', 'G5')) plt.yticks(np.arange(0, max(cumulative), 30)) plt.legend(legends, range(1, len(legends) + 1)) plt.show()