Skip to content

docs: add subplot-mosaic string compact notation #23006

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 2 commits into from
May 8, 2022
Merged
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
24 changes: 20 additions & 4 deletions tutorials/provisional/mosaic.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def identify_axes(ax_dict, fontsize=48):
# String short-hand
# =================
#
# By restricting our axes labels to single characters we can use Using we can
# By restricting our axes labels to single characters we can
# "draw" the Axes we want as "ASCII art". The following


Expand All @@ -123,14 +123,30 @@ def identify_axes(ax_dict, fontsize=48):
ax_dict = fig.subplot_mosaic(mosaic)
identify_axes(ax_dict)

###############################################################################
# Alternatively, you can use the more compact string notation
mosaic = "AB;CD"

###############################################################################
# will give you the same composition, where the ``";"`` is used
# as the row separator instead of newline.

fig = plt.figure(constrained_layout=True)
ax_dict = fig.subplot_mosaic(mosaic)
identify_axes(ax_dict)

###############################################################################
# Axes spanning multiple rows/columns
# ===================================
#
# Something we can do with `.Figure.subplot_mosaic` that you can not
# do with `.Figure.subplots` is specify that an Axes should span
# several rows or columns.
#
# If we want to re-arrange our four Axes to have C be a horizontal
# span on the bottom and D be a vertical span on the right we would do


###############################################################################
# If we want to re-arrange our four Axes to have ``"C"`` be a horizontal
# span on the bottom and ``"D"`` be a vertical span on the right we would do

axd = plt.figure(constrained_layout=True).subplot_mosaic(
"""
Expand Down