首先,全局引入需要的库和字体设置
import random
from matplotlib import pyplot as plt
import matplotlib
font = {
- ‘family’:‘SimHei’,
‘weight’:‘bold’,
‘size’:12
}
matplotlib.rc(“font”, **font)
案例1.子图矩阵
fig,axs = plt.subplots(3,3)
axs[0,1].scatter(range(20),range(20))
axs[0,2].scatter(range(25),range(25),color=“b”)
axs[1,0].scatter(range(30),range(30),color=“g”)
axs[1,1].scatter(range(35),range(35),color=“y”)
axs[1,2].scatter(range(45),range(45),color=“c”)
axs[0,1].scatter(range(40),range(40),color=“m”)
axs[2,1].scatter(range(40),range(40),color=“r”)
axs[2,0].scatter(range(30),range(30))
案例2.折线图练习
x=[1,2,3,4,6,5,10]
y