0

我是初学者,编写了以下代码:

wn=np.random.normal(loc=raw_data.Quantity.mean(), scale=raw_data.Quantity.std(), size=len(training_data))
training_data['wn']=wn
 training_data.wn.plot(figsize=(20,5), title="LOL")
plt.title('White Noise')
plt.ylim(0,2400)
plt.show()     

它给出了以下错误:

AttributeError:“numpy.ndarray”对象没有属性“plot”

以下是白噪声的值:

In[140]:wn
Out[140]: array([313.12254531, 43.56086818, 298.21441411, ..., -50.96308586, 193.43057718, 242.80841993])

谁能帮我解决这个问题?

4

2 回答 2

0

您描述的错误是因为您试图让 numpy 生成绘图(numpy 不进行绘图),而看起来您想使用matplotlib进行绘图。

替换training_data.wn.plot(figsize=(20,5), title="LOL")plt.plot(wn,'.'),这将绘制每个点。

如果没有更多信息,很难更具体地了解情节。上面的 Thie 将依次绘制每个点并随着每个点沿 x 轴递增(即,如果有 1000 个点,则 x 轴将从 0-999 运行,每个点绘制 1 个点。

于 2020-02-04T16:31:55.013 回答
0

不要在数组本身上调用plot方法,而是尝试运行

plt.plot(wn)
于 2020-02-04T15:06:40.860 回答