Skip to content

Commit d3c77af

Browse files
timhoffmmeeseeksmachine
authored andcommitted
Backport PR #30029: Update diagram in subplots_adjust documentation to clarify parameters
1 parent 3b85ba4 commit d3c77af

File tree

1 file changed

+22
-16
lines changed

1 file changed

+22
-16
lines changed
Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,34 @@
11
import matplotlib.pyplot as plt
22

33

4-
def arrow(p1, p2, **props):
5-
axs[0, 0].annotate(
6-
"", p1, p2, xycoords='figure fraction',
7-
arrowprops=dict(arrowstyle="<->", shrinkA=0, shrinkB=0, **props))
8-
9-
104
fig, axs = plt.subplots(2, 2, figsize=(6.5, 4))
115
fig.set_facecolor('lightblue')
126
fig.subplots_adjust(0.1, 0.1, 0.9, 0.9, 0.4, 0.4)
7+
8+
overlay = fig.add_axes([0, 0, 1, 1], zorder=100)
9+
overlay.axis("off")
10+
xycoords='figure fraction'
11+
arrowprops=dict(arrowstyle="<->", shrinkA=0, shrinkB=0)
12+
1313
for ax in axs.flat:
1414
ax.set(xticks=[], yticks=[])
1515

16-
arrow((0, 0.75), (0.1, 0.75)) # left
17-
arrow((0.435, 0.75), (0.565, 0.75)) # wspace
18-
arrow((0.9, 0.75), (1, 0.75)) # right
16+
overlay.annotate("", (0, 0.75), (0.1, 0.75),
17+
xycoords=xycoords, arrowprops=arrowprops) # left
18+
overlay.annotate("", (0.435, 0.25), (0.565, 0.25),
19+
xycoords=xycoords, arrowprops=arrowprops) # wspace
20+
overlay.annotate("", (0, 0.8), (0.9, 0.8),
21+
xycoords=xycoords, arrowprops=arrowprops) # right
1922
fig.text(0.05, 0.7, "left", ha="center")
20-
fig.text(0.5, 0.7, "wspace", ha="center")
21-
fig.text(0.95, 0.7, "right", ha="center")
23+
fig.text(0.5, 0.3, "wspace", ha="center")
24+
fig.text(0.05, 0.83, "right", ha="center")
2225

23-
arrow((0.25, 0), (0.25, 0.1)) # bottom
24-
arrow((0.25, 0.435), (0.25, 0.565)) # hspace
25-
arrow((0.25, 0.9), (0.25, 1)) # top
26-
fig.text(0.28, 0.05, "bottom", va="center")
26+
overlay.annotate("", (0.75, 0), (0.75, 0.1),
27+
xycoords=xycoords, arrowprops=arrowprops) # bottom
28+
overlay.annotate("", (0.25, 0.435), (0.25, 0.565),
29+
xycoords=xycoords, arrowprops=arrowprops) # hspace
30+
overlay.annotate("", (0.8, 0), (0.8, 0.9),
31+
xycoords=xycoords, arrowprops=arrowprops) # top
32+
fig.text(0.65, 0.05, "bottom", va="center")
2733
fig.text(0.28, 0.5, "hspace", va="center")
28-
fig.text(0.28, 0.95, "top", va="center")
34+
fig.text(0.82, 0.05, "top", va="center")

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy