Description
when I try this example, I find that there is a tiny bug in line 21:
"Get some pastel shades for the colors"
colors = plt.cm.BuPu(np.linspace(0, 0.5, len(columns)))
well, the columns here should be rows, as we want to give different colors by row index.
there is no problem in this example, because the matrix here is 5*5.
But if the length of rows is bigger than that of columns, it will raise Exception, such as
plt.bar(index, data[row], bar_width, bottom=y_offset, color=colors[row])
IndexError: index 2 is out of bounds for axis 0 with size 2
related lines are as follows:
columns = ('Freeze', 'Wind', 'Flood', 'Quake', 'Hail')
rows = ['%d year' % x for x in (100, 50, 20, 10, 5)]
values = np.arange(0, 2500, 500)
value_increment = 1000
" Get some pastel shades for the colors"
colors = plt.cm.BuPu(np.linspace(0, 0.5, len(columns)))
n_rows = len(data)