散布図のscatterメソッドは次のように記述します。
fig, ax = plt.subplots()
乱数のシード値を固定
np.random.seed(0)
NumPyのrandom.rand関数で0〜1の範囲で10個の乱数を作成
x1 = np.random.rand(10)
y1 = np.random.rand(10)
x2 = np.random.rand(10)
y2 = np.random.rand(10)
scatterメソッドの第1引数でx軸の値、第2引数でy軸の値を指定
ax.scatter(x1, y1, label='データ1')
ax.scatter(x2, y2, label='データ2')
凡例を表示
ax.legend()