空图归一化值

Emplty plot normalised values

想要在数组中绘制归一化值但得到的是空图

import numpy as np
x_array = np.array([2,3,5,6,7,4,8,7,6])
normalized_arr = preprocessing.normalize([x_array])
print(normalized_arr)

plt.plot(normalized_arr)
plt.show()

空图 - https://i.stack.imgur.com/NnSbI.png

有没有函数可以用值填充空图?

您可能需要将代码更改为:

import numpy as np
import matplotlib.pyplot as plt
from sklearn import preprocessing
x_array = np.array([2,3,5,6,7,4,8,7,6])
normalized_arr = preprocessing.normalize([x_array])
print(normalized_arr)

plt.plot(x_array.reshape(-1,1),normalized_arr.reshape(-1,1))
plt.show()

输出