我有以下代码:
import scipy as sc
import matplotlib.pyplot as plt
....
MeanSquareDistance1D=lambda n,m: ((m*Lastpoint1d(n)**2).sum())/m
......
data=[]
for i in range(10,110,20):
#mydata=list(sc.mat([[i],[MeanSquareDistance1D(i,2000)]]))
#data.append(mydata)
mydata=(sc.array([i,MeanSquareDistance1D(i,2000)])).tolist() I did it like this
data.append(mydata)
plt.plot(data)
plt.show()
我希望'mydata'是一个矩阵或数组(最好)(我将它转换为一个列表以便绘制图表),有i行(5行)和2列。 第一列应为'i',第二列应为MeanSquareDistance1D(i,2000)的值。 我收到错误'ValueError:x,y可以不大于2-D'
答案 0 :(得分:0)
import scipy as sc
import matplotlib.pyplot as plt
....
MeanSquareDistance1D=lambda n,m: ((m*Lastpoint1d(n)**2).sum())/m
......
data=[]
for i in range(10,110,20):
#mydata=list(sc.mat([[i],[MeanSquareDistance1D(i,2000)]]))
#data.append(mydata)
mydata=(sc.array([i,MeanSquareDistance1D(i,2000)])).tolist() I did it like this
data.append(mydata)
plt.plot(data)
plt.show()