目录
1、安装所需要的库
pip install numpy
pip install matplotlib
pip install pandas
2、引入模块
#d导入相关库
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
#设置中文
plt.rcParams['font.sans-serif'] = ['SimHei']
3、图的类型
3.1、散点图
#随机散点图
x = list(np.arange(0,5,0.5))
y = np.random.rand(10)
#散点图函数绘图
plt.scatter(x,y)
#设置标题
plt.title("散点图",fontsize =20)
#设置x轴
plt.xlabel("自变量",fontsize = 14)
#设置y轴
plt.ylabel("因变量",fontsize = 14)
#指定数据散点图
x = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]
y =[98.5,98.9,99,99.6,99.8,100.6,101.6,101.2,101.9,102,103.2,