理解fig,ax = plt.subplots()

fig,ax = plt.subplots()等价于:

  1. fig = plt.figure()
  2. ax = fig.add_subplot(1,1,1)

fig, ax = plt.subplots(1,3),其中参数1和3分别代表子图的行数和列数,一共有 1x3 个子图像。函数返回一个figure图像和子图ax的array列表。

fig, ax = plt.subplots(1,3,1),最后一个参数1代表第一个子图。

如果想要设置子图的宽度和高度可以在函数内加入figsize值

fig, ax = plt.subplots(1,3,figsize=(15,7)),这样就会有1行3个15x7大小的子图。

猜你喜欢

转载自blog.csdn.net/xavier_muse/article/details/83859272
plt