1.首先安装matplotlib
pip install matplotlib
2.引入matplotlib
import matplotlib.pyplot as plt
import numpy as np
3.matplotlib散点图
# 散点图 scatter(x ,y ,...) x y 为数组
# uniform 均匀分布随机采样
arr1 = np.random.uniform(0.0, 5.0, size=(100, 2)) # 100行 2列的元组
print(arr1)
arr2 = np.random.uniform(4.2, 10, size=(100, 2)) # 100行 2列的元组
print(arr2)
# 保存数据
np.savetxt('./matplot_test_data1.txt', arr1, fmt='%f %f',
delimiter='\n') # fmt 格式小数点 delimiter分隔符
np.savetxt('./matplot_test_data2.txt', arr2, fmt='%f %f',
delimiter='\n') # fmt 格式小数点 delimiter分隔符
# 读取数据
a = np.loadtxt('./matplot_test_data1.txt')
b = np.loadtxt('./matplot_test_data2.txt')
"""
[
[9.2991324 7.36309413]
...
[6.70664