Python 绘制多轴对象阵列
我有一个4x4 numpy数组,Python 绘制多轴对象阵列,python,matplotlib,plot,Python,Matplotlib,Plot,我有一个4x4 numpy数组,ax,其中每个元素都是一个对象 这就是ax的外观 >>> ax array([[<matplotlib.axes._subplots.AxesSubplot object at 0x124366f98>, <matplotlib.axes._subplots.AxesSubplot object at 0x1246d0160>, <matplotlib.axes._subplots.A
ax
,其中每个元素都是一个
对象
这就是ax的外观
>>> 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)
如何绘制
AxesSubplot
类的集合?您必须循环遍历AxesSubplot
实例并调用fig.axes.append(ax)
我发现这是一个参考:plt.show()
不接受任何参数,除了True
或False
之外。我不明白问题的其余部分。轴阵列是图形的一部分;所以你需要显示这个数字。我刚刚意识到我犯的错误。我只返回函数中的轴部分。我把它改成了返回数字。我对它调用.show()
方法,它就工作了。这篇文章看起来像是大脑衰退的产物。谢谢你的意见。
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()