考虑
import numpy as np
import matplotlib.pyplot as plt
data = np.zeros((3, 3))
fig = plt.figure()
ax1 = plt.subplot(131)
ax2 = plt.subplot(132)
ax3 = plt.subplot(133)
axes = [ax1, ax2, ax3]
for ax in axes:
im = ax.imshow(data)
结果数字fig
有3个AxesSubplot
个孩子,每个子图一个。它们的几何形状
for child in fig.get_children():
try:
print(child.get_geometry())
except AttributeError:
pass
(1, 3, 1)
(1, 3, 2)
(1, 3, 3)
有道理。
现在让我们添加一些颜色条:
for ax in axes:
fig.colorbar(im, ax=ax, orientation='horizontal')
现在将几何图形报告为
(2, 1, 1)
(2, 1, 1)
(2, 1, 1)
(1, 3, 2)
(1, 3, 2)
(1, 3, 2)
嗯,怎么理解那些?