我正在嘗試將 python 與 jupyter notebook 結(jié)合使用,想出一個(gè)方案,您可以握住智能燈泡并通過漫反射從手中獲取信息。我已經(jīng)設(shè)法完成所有這些工作,并且所有這些都保存在一個(gè)變量 PIX 中:PIX = np.array(pictures)print(PIX.shape)這會(huì)像預(yù)期的那樣輸出一個(gè) (81,480,640,3)(81 表示轉(zhuǎn)換為 RGB 的可見光譜,以便燈得到它)。但是,我現(xiàn)在想可視化數(shù)據(jù),我認(rèn)為 imshow 是完美的實(shí)現(xiàn)。我更改了一些變量,使腳本如下所示:# Plot the images on a subplots array?fig, axes =?plt.subplots(int(PIX.shape[0]/9),int(PIX.shape[0]/9))for i, ax in enumerate(axes):? ? axes[i].imshow(PIX[i,:,:,0], interpolation='none')# Render the figureplt.show()同樣,這非常簡(jiǎn)單。但是,我收到錯(cuò)誤:AttributeError? ? ? ? ? ? ? ? ? ? ? ? ? ? Traceback (most recent call last)<ipython-input-20-a7bb604d1828> in <module>? ? ? 3?? ? ? 4 for i, ax in enumerate(axes):----> 5? ? ?axes[i].imshow(PIX[i,:,:,0], interpolation='none')? ? ? 6 # Render the figure? ? ? 7 plt.show()AttributeError: 'numpy.ndarray' object has no attribute 'imshow'?我嘗試使用 matplotlib修復(fù)'numpy.ndarray' object has no attribute 'imshow'和'numpy.ndarray' object has no attribute 'show'?,他們似乎有類似的問題。但是,這些修復(fù)似乎都不適用于我的情況。任何幫助,將不勝感激!
numpy.ndarray 對(duì)象沒有屬性 imshow
慕蓋茨4494581
2023-05-23 15:04:41