一、折线图
import matplotlib.pyplot as plt
# 创建画布
plt.figure(figsize=(10,10), dpi=100) #指定长宽、清晰度
#绘制图像
plt.plot([1,2,4,7,1,3,4,6,2])
#显示图片
plt.show()
二、基础绘图功能
import matplotlib.pyplot as plt
import random
#准备数据
x = range(60)
y = [random.uniform(15,18) for i in x]
# 创建画布
plt.figure(figsize=(15,5), dpi=100) #指定长宽、清晰度
#绘制图像
plt.plot(x,y)
#显示图片
plt.show()
(1)添加自定义x,y刻度
import matplotlib.pyplot as plt
import random
#0 准备数据
x = range(60)
y = [random.uniform(15,18) for i in x]
#1 创建画布
plt.figure(figsize=(15,