>>> M = NP.empty((5, 5), dtype=NP.object) # a 2D NumPy array
>>> M
array([[None, None, None, None, None],
[None, None, None, None, None],
[None, None, None, None, None],
[None, None, None, None, None],
[None, None, None, None, None]], dtype=object)
これで、 ValueErrorを取得せずにシーケンスを挿入できます
>>> M[2,2] = NP.array([4, 3, 5])
>>> M
array([[None, None, None, None, None],
[None, None, None, None, None],
[None, None, [4 3 5], None, None],
[None, None, None, None, None],
[None, None, None, None, None]], dtype=object)
>>> M[2,2]
array([4, 3, 5])
OPの他の部分(このような配列をMatplotlibのimshowに渡す)は問題です。
imshowは、2D配列を、x、yインデックスに従ってキャンバス上に配置された点群として視覚的に表します。そのインデックスの値は、色を配列値にマップするカラーマップに基づいて、さまざまな色と色の強度に従って示されます。したがって、 imshowのデータパラメータ
imshowが次のように解釈できる2つ(およびこれら2つのAFAIKのみ)の高次元のNumPy配列