Skip to content
Advertisement

How to fix ‘numpy.ndarray’ object has no attribute ‘get_figure’ when plotting subplots

I have written the following code to plot 6 pie charts in different subplots, but I get an error. This code works correctly if I use it to plot only 2 charts, but produces an an error for anything more than that.

I have 6 categorical variables in my dataset, the names of which are stored in the list cat_cols. The charts are to be plotted from the training data train.

CODE

JavaScript

ERROR

JavaScript

How do we rectify this?

Advertisement

Answer

  • The issue is plt.subplots(2, 3, figsize=(24, 10)) creates two groups of 3 subplots, not one group of six subplots.
JavaScript
JavaScript

enter image description here

Advertisement