Skip to content

DOC: Add illustration to Figure.subplots_adjust #28844

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions doc/_embedded_plots/figure_subplots_adjust.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,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")
2 changes: 2 additions & 0 deletions lib/matplotlib/figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -1322,6 +1322,8 @@ def subplots_adjust(self, left=None, bottom=None, right=None, top=None,
Unset parameters are left unmodified; initial values are given by
:rc:`figure.subplot.[name]`.

.. plot:: _embedded_plots/figure_subplots_adjust.py

Parameters
----------
left : float, optional
Expand Down
Loading