Time Series Visualizer Bar Plot ERRORs


So I managed to finish the bar plot, visually at least. Everything looks pretty identical to the example. However, I do not pass any of the tests and I keep getting these errors:

TypeError: ‘AxesSubplot’ object is not subscriptable


Killed exit status 137

My code is definitely not clean either, I’m not sure if that is messing with my memory or if it’s just my laptop. I’ve seen other people have the second issue too but no clear answers. Any help or suggestions would be greatly appreciated.

This is a common error in these projects and there are several posts here about it for this project and the heatmap. This is cause by not returning a matplotlib fig object when the test runs. The problem is

    # Save image and return fig (don't change this part)
    return fig

I’m not sure what type of object fig is (seaborn returns a FacetGrid for example, but you’re using pandas to plot and I don’t know what kind of object it returns), but you need to return the part of that object that is a matplotlib fig with appropriate axes objects in it. It looks like fig.figure is actually the matplotlib fig object you should be returning. You can search forums for more examples of how to return the correct object for the tests in these projects.

Oh I see, thank you. The directions didn’t specify what to use for the bar graph so I thought we were free to use whatever. Thank you I’ll try to rework some things around

You can use whichever plotting package you like, you just have to get a matplotlib fig for the test to be happy. Most python plotting packages build their plot objects from matplotlib, so it’s just a matter of reading the specific documentation (for pandas in your case) to see how their plots are constructed and how to get the fig and axes parts to the test.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.