用法
通常使用 fig, ax = plt.subplots() 可以创建多张子图,而plt.subplot() 通常用来区别各个子图
# create a subplot with 2 rows and 1 columns
fig, ax = plt.subplots(2,1)
fig = plt.figure() # create the canvas for plotting
ax1 = plt.subplot(2,1,1)
# (2,1,1) indicates total number of rows, columns, and figure number respectively
ax2 = plt.subplot(2,1,2)
ax3 = plt.subplot(2,1,3)
fig, axes = plt.subplots(nrows=2, ncols=3)
# first you have to make the figure
fig = plt.figure(1)
# now you have to create each subplot individually
ax1 = plt.subplot(231)
ax2 = plt.subplot(232)
ax3 = plt.subplot(233)
ax4 = plt.subplot(234)
ax5 = plt.subplot(235)
ax6 = plt.subplot(236)
本文详细介绍如何使用Matplotlib库创建多子图,包括不同布局的子图设置方法,如2行1列、3列2行等,以及如何在创建画布后单独添加子图。
582

被折叠的 条评论
为什么被折叠?



