大概有这么几种吧
.Figure.add_subplot
.Figure.add_axes
.pyplot.subplot
.pyplot.axes
.Figure.subplots
.pyplot.subplots
1 .Figure.add_subplot
https://matplotlib.org/stable/api/figure_api.html?highlight=figure%20add_subplot#matplotlib.figure.Figure.add_subplot
fig = plt.figure()
fig.add_subplot(231)
ax1 = fig.add_subplot(2, 3, 1) # equivalent but more general
fig.add_subplot(232, frameon=False) # subplot with no frame
fig.add_subplot(233, projection='polar') # polar subplot
fig.add_subplot(234, sharex=ax1) # subplot sharing x-axis with ax1
fig.add_subplot(235, facecolor="red") # red subplot
ax1.remove() # delete ax1 from the figure
fig.add_subplot(ax1) # add ax1 back to the figure
2 .Figure.add_axes
https://matplotlib.org/stable/api/figure_api.html?highlight=figure%20add_subplot#matplotlib.figure.Figure.add_axes
rect = l, b, w, h
fig = plt.figure()
fig.add_axes(rect)
fig.add_axes(rect, frameon=False, facecolor='g')
fig.add_axes(rect, polar=True)
ax = fig.add_axes(rect, projection='polar'</