サンプルコード
githubにあげてあります。
https://github.com/tocom242242/aifx_blog_codes/blob/master/matplotlib_samples/scatter.ipynb
まず必要なライブラリをimportします。
import matplotlib.pyplot as plt
import numpy as np
データの作成
x = np.random.random(20)
y = np.random.random(20)
print(f"x:{x}")
print(f"y:{y}")
出力
x:[0.78176986 0.82890655 0.17201511 0.40632955 0.94072404 0.57510522
0.96498484 0.08871191 0.93486596 0.90505944 0.95108657 0.57259264
0.08828654 0.08116361 0.40660873 0.5487279 0.35501224 0.82654318
0.855207 0.14521377]
y:[0.56767039 0.25243398 0.16335288 0.58262353 0.93961818 0.62856973
0.63194413 0.11973044 0.14676694 0.93176879 0.61021364 0.7510278
0.0903804 0.10020713 0.38177483 0.01433844 0.10344041 0.4241432
0.63520594 0.29786765]
散布図をプロット
plt.scatter(x,y)