plt.plot(x, y, 'xxx', label=, linewidth=)
参数1:位置参数,点的横坐标,可迭代对象
参数2:位置参数,点的纵坐标,可迭代对象
参数3:位置参数,点和线的样式,字符串
此参数分三部分,点线的颜色、点的形状、线的形状
点线的颜色:g | green;b | blue;c | cyan 蓝绿色;m - magenta 品红色 ...
点的形状:. | 点儿;v | 实心倒三角;o | 实心圆;* | 实心五角星;+ | 加号 ...
线的形状:- | 实线;-- | 虚线;-. 点划线
参数 4:label 关键字参数,设置图例,需要调用 plt 或子图的 legend 方法
参数 5:linewidth 关键字参数,设置线的粗细
import matplotlib.pyplot as plt
plt.figure(1) plt.plot([0, 1], [0, 1], 'm.') #涉及plot点线的知识参考 plt.plot(index, y_test, 'm.', label='True value') plt.plot(index, y_pred, 'c*', label='Pred value') plt.xlabel('data index ') plt.ylabel('label value') plt.title('Pred and True label picture') plt.legend(loc='best') # 控制图片显示的位置 plt.show()