Medical Data Visualizer AttributeError: 'numpy.ndarray' object has no attribute

I completed the project on google colab and everything seems to be working once I copy it over to replit. The charts seem to look good. However, I’m getting the following 2 errors on test:

======================================================================
ERROR: test_bar_plot_number_of_bars (test_module.CatPlotTestCase)

Traceback (most recent call last):
File “/home/runner/boilerplate-medical-data-visualizer/test_module.py”, line 26, in test_bar_plot_number_of_bars
actual = len([rect for rect in self.ax.get_children() if isinstance(rect, mpl.patches.Rectangle)])
AttributeError: ‘numpy.ndarray’ object has no attribute ‘get_children’

======================================================================
ERROR: test_line_plot_labels (test_module.CatPlotTestCase)

Traceback (most recent call last):
File “/home/runner/boilerplate-medical-data-visualizer/test_module.py”, line 13, in test_line_plot_labels
actual = self.ax.get_xlabel()
AttributeError: ‘numpy.ndarray’ object has no attribute ‘get_xlabel’


I could not find much information about these errors. I’ve tried updating dependencies and updating pyproject.toml but it didn’t seem to change anything.

Any ideas?

Link to replit: PKDV-fcc-medical-data-visualizer-NEW - Replit

You’re not handling your fig correctly in the catplot as opposed to the heatmap. sns.catplot() returns a seaborn FacetGrid object, not a matplotlib Figure or Axes. The issue has been solved several times in the forums or you can read the seaborn documentation about FacetGrid objects.

Found it, thank you

For future coders:
You need to convert the Seaborn FacetGrid object stored in fig to a matplotlib Figure object by adding this line before the save:
fig = fig.figure

http://seaborn.pydata.org/generated/seaborn.FacetGrid.html
Screenshot 2023-05-11 230831