Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python

Error with table() method on matplotlib

Hey guys, I'm getting the following error when using matplotlib's method table(). I'm running python 3, maybe this is why I get an error?

File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/matplotlib/table.py", line 478, in table rows = len(cellColours) TypeError: object of type 'NoneType' has no len()

I can't find anything on stack overflow. This is my code:

def plot_table_for_bar_chart(cell_text, row_text, columns):
    plt.style.use('ggplot')
    fig = plt.figure()

    ax2 = fig.add_subplot(111)
    ax2.axis('off')

    the_table = ax2.table(carllText=cell_text, rowLabels=row_text,colLabels=columns,loc='bottom')

1 Answer

I think you have a typo carllText=cell_text in your table method call:

the_table = ax2.table(carllText=cell_text, rowLabels=row_text,colLabels=columns,loc='bottom')

Probably should be cellText=cell_text?

I can't believe it... I swear i checked everything 3 or 4 times and I never saw the typo.

Thanks Lain :)