Python matplotlib画图出现No handles with labels found to put in legend
这种错误是代表无法在图中显示标签,有两种可能。
第一种:plt.scatter() 中缺乏label = “xx”
或者
第二种:plt.scatter(),plt.figure() 顺序错误
第一种:plt.scatter() 中缺乏label = “xx”
plt.legend()就是为了展示标签,前面函数中没有定义,自然无法显示
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
X = np.random.randn(10,2) #10行,2列的数据集
Y = np.array([0,0,1,1,0,1,0,1,0,0
plt.scatter