I have a 4x4 numpy array, ax
, where each element is an <class 'matplotlib.axes._subplots.AxesSubplot'>
object.
This is how ax
looks
>>> ax
array([[<matplotlib.axes._subplots.AxesSubplot object at 0x124366f98>,
<matplotlib.axes._subplots.AxesSubplot object at 0x1246d0160>,
<matplotlib.axes._subplots.AxesSubplot object at 0x124392710>,
<matplotlib.axes._subplots.AxesSubplot object at 0x125c0cdd8>],
[<matplotlib.axes._subplots.AxesSubplot object at 0x1270032b0>,
<matplotlib.axes._subplots.AxesSubplot object at 0x127124908>,
<matplotlib.axes._subplots.AxesSubplot object at 0x12afcaf98>,
<matplotlib.axes._subplots.AxesSubplot object at 0x127176668>],
[<matplotlib.axes._subplots.AxesSubplot object at 0x127170cf8>,
<matplotlib.axes._subplots.AxesSubplot object at 0x124b1e3c8>,
<matplotlib.axes._subplots.AxesSubplot object at 0x1270c2a58>,
<matplotlib.axes._subplots.AxesSubplot object at 0x124aeb128>],
[<matplotlib.axes._subplots.AxesSubplot object at 0x124b0d7b8>,
<matplotlib.axes._subplots.AxesSubplot object at 0x12af52e48>,
<matplotlib.axes._subplots.AxesSubplot object at 0x124a96518>,
<matplotlib.axes._subplots.AxesSubplot object at 0x12910cba8>]],
dtype=object)
I need to plot each of these as a subplot in a four by four plot. This is what I am trying to get (ignore the dimensions of this plot)
I tried the simple plt.show(ax)
but I obviously ran into errors since ax
is a collection of AxesSubplot
class. I also tried looping through the ax
array and plotting but I got the same error as I got when I ran plt.show(ax)
. This is the error
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.7/site-packages/matplotlib/pyplot.py", line 253, in show
return _show(*args, **kw)
File "/usr/local/lib/python3.7/site-packages/matplotlib/backend_bases.py", line 207, in show
if block:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
How do I plot a collection of AxesSubplot
classes?