Skip to content

bug in matplotlib/examples/pylab_examples/table_demo.py #5005

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
xuanyuansen opened this issue Aug 28, 2015 · 0 comments
Closed

bug in matplotlib/examples/pylab_examples/table_demo.py #5005

xuanyuansen opened this issue Aug 28, 2015 · 0 comments

Comments

@xuanyuansen
Copy link
Contributor

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant