-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Closed
Description
Note: This is from a stackoverflow question.
Consider
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)The resulting figure fig has 3 AxesSubplot children, one for each subplot. Their geometry
for child in fig.get_children():
try:
print(child.get_geometry())
except AttributeError:
pass(1, 3, 1)
(1, 3, 2)
(1, 3, 3)
makes sense.
Now let's add some color bars:
for ax in axes:
fig.colorbar(im, ax=ax, orientation='horizontal')Now the geometries are reported as
(2, 1, 1)
(2, 1, 1)
(2, 1, 1)
(1, 3, 2)
(1, 3, 2)
(1, 3, 2)
All information about how the plots are arranged seems lost.
I guess I would have expected a nested structure: The three plots are children of fig with the ordering
(1, 3, 1), (1, 3, 2), (1, 3, 3), and each of those has two subplots with the ordering (2, 1, 1), (2, 1, 2).
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels