pyplot.subplot python code example
Example 1: subplots matplotlib
x = np.linspace(0, 2*np.pi, 400)
y = np.sin(x**2)
fig, ax = plt.subplots()
ax.plot(x, y)
ax.set_title('Simple plot')
f, (ax1, ax2) = plt.subplots(1, 2, sharey=True)
ax1.plot(x, y)
ax1.set_title('Sharing Y axis')
ax2.scatter(x, y)
fig, axs = plt.subplots(2, 2, subplot_kw=dict(polar=True))
axs[0, 0].plot(x, y)
axs[1, 1].scatter(x, y)
plt.subplots(2, 2, sharex='col')
plt.subplots(2, 2, sharey='row')
plt.subplots(2, 2, sharex='all', sharey='all')
plt.subplots(2, 2, sharex=True, sharey=True)
fig, ax = plt.subplots(num=10, clear=True)
Example 2: get subplots in matplotlib
fig,ax = plt.subplots(3,2,figsize=(25,10),)
i,j = 0,0
for each in list_of_images:
img = cv.imread(each.name)
ax[i,j].imshow(img)
if j == 1:
j = 0
if i != 2:
i += 1
else:
j += 1