0
我試圖繪製從numpy的陣列的各列求和而獲得數組值。 在Win XP,Python 2.5的工作,matplotlib-1.0.1,numpy的-1.5.1,PIL-1.1.7 下面是代碼:pyplot陣列的崩潰
import Image
import numpy as np
import matplotlib.pyplot as plt
im = Image.open("tish.pnm")
im = im.convert("1") # convert necessary to import into numpy array
pixels = im.getdata()
n = len(pixels)
data = np.reshape(pixels, im.size)
sums = {}
#sum the range of column values
for i in range(0, data.shape[0]):
sums[i] = data[:,i].sum()
#this is where I can't get pyplot to work
plt.plot(sums) # this crashes with a "ValueError: need more than 0 values to unpack"
plt.plot(i,sums) #crashes with the same error
當我做了一個 「打印總和」 我得到數據如:
{0: 705330, 1: 667845, 2: 693855, 3: 663000, 4: 699210, 5: 660705, 6: 686970, 7: 662490, 8: 697425, 9: 660450, 10: 688500, 11: 663510,...2913:65295}
我在做什麼錯?
謝謝位有關加載的金額到一個數組是我需要的,但沒有找到。 – user652221 2011-03-09 20:50:54