Data Analysis with Python Projects - Medical Data Visualizer

Tell us what’s happening:

i try to test my code and i have 2 different problems:
AttributeError: ‘numpy.ndarray’ object has no attribute ‘get_children’
AttributeError: ‘numpy.ndarray’ object has no attribute ‘get_xlabel’
i think the problem is the version of matplotlib, or maybe the test code is old?
https://freecodecam-boilerplate-c7emtcc2lf6.ws-eu120.gitpod.io/
my code is here.

Your code so far

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36

Challenge Information:

Data Analysis with Python Projects - Medical Data Visualizer

1 Like

we are not able to access that link, you need to share a snapshot

Encountered the same error when I tested the catplot.

Here’s the error:

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

Traceback (most recent call last):
File “/workspace/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 (main.CatPlotTestCase)

Traceback (most recent call last):
File “/workspace/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 was also wondering why is that the case since I was able to replicate the output figure needed using seaborn catplot.

1 Like

I went through the error, and it seems the test code expects a single Axes object but is receiving a NumPy ndarray of Axes instead. To fix this, you should extract a single Axes from the array or from the facetgrid before calling .get_children() or .get_xlabel(). This is not an issue with the matplotlib version, but rather a usage mismatch. Let us know if this works. Good Luck!

1 Like

hi auberlychen, i think the problem comes from the catplot library, i dont know what can i do to fix it.

hi, i try but i have the same error.

Hi, please open your own thread if you need help with this.

Please share your code. You can paste it here or share a snapshot of gitpod.

Maybe it’s related to this:

https://forum.freecodecamp.org/t/data-analysis-with-python-projects-medical-data-visualizer/648627

thanks a lot, it works!

1 Like