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/”, line 26, in test_bar_plot_number_of_bars
actual = len([rect for rect in 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/”, line 13, in test_line_plot_labels
actual =
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: boilerplate-medical-data-visualizer - 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.

1 Like

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
Screenshot 2023-05-11 230831

1 Like

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