matplotlib绘图
程序员文章站
2022-03-01 15:51:32
...
"""python绘制散点图"""
from matplotlib import pyplot as plt
import numpy as np
train_x = np.linspace(-1, 1, 100)
train_y_1 = 2*train_x + np.random.rand(*train_x.shape)*0.3
train_y_2 = train_x**2+np.random.randn(*train_x.shape)*0.3
plt.scatter(train_x, train_y_1, c='red', marker='v' )
plt.scatter(train_x, train_y_2, c='blue', marker='o' )
plt.legend(["red","Blue"], loc="upper lift")
plt.show()
上一篇: 实验10 静态路由配置
下一篇: matplotlib绘图