File: figure_subplots_adjust.py

package info (click to toggle)
matplotlib 3.10.1%2Bdfsg1-4
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 78,352 kB
  • sloc: python: 147,118; cpp: 62,988; objc: 1,679; ansic: 1,426; javascript: 786; makefile: 104; sh: 53
file content (28 lines) | stat: -rw-r--r-- 894 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import matplotlib.pyplot as plt


def arrow(p1, p2, **props):
    axs[0, 0].annotate(
        "", p1, p2,  xycoords='figure fraction',
        arrowprops=dict(arrowstyle="<->", shrinkA=0, shrinkB=0, **props))


fig, axs = plt.subplots(2, 2, figsize=(6.5, 4))
fig.set_facecolor('lightblue')
fig.subplots_adjust(0.1, 0.1, 0.9, 0.9, 0.4, 0.4)
for ax in axs.flat:
    ax.set(xticks=[], yticks=[])

arrow((0, 0.75), (0.1, 0.75))  # left
arrow((0.435, 0.75), (0.565, 0.75))  # wspace
arrow((0.9, 0.75), (1, 0.75))  # right
fig.text(0.05, 0.7, "left", ha="center")
fig.text(0.5, 0.7, "wspace", ha="center")
fig.text(0.95, 0.7, "right", ha="center")

arrow((0.25, 0), (0.25, 0.1))  # bottom
arrow((0.25, 0.435), (0.25, 0.565))  # hspace
arrow((0.25, 0.9), (0.25, 1))  # top
fig.text(0.28, 0.05, "bottom", va="center")
fig.text(0.28, 0.5, "hspace", va="center")
fig.text(0.28, 0.95, "top", va="center")