本文主要是使用python画散点图,对二维数据进行简单分析。
主要用到的库有matplotlib
如果运行过程中提示错误
import matplotlib.pyplot as plt
ModuleNotFoundError: No module named 'matplotlib'
使用下面命令行安装matplotlib库即可。
pip install matplotlib
linux环境代码:
import matplotlib.pyplot as plt
from random import randint
# 随机生成简单数据
x=[]
y=[]
for i in range(1000):
x.append(randint(1,100))
y.append(randint(1,100))
mi =1
mx = 100
plt.title("Scatter point diagram", fontsize=24)
plt.xlim(xmax=mx,xmin=mi)
plt.ylim(ymax=mx,ymin=mi)
plt.plot(x,y,'ro')
plt.savefig('result.jpg')
运行结果: