Skip to content

Commit bb3519d

Browse files
dmatos2012David Matostimhoffmoscargus
authored
DOC: add subplot-mosaic string compact notation (#23006)
Co-authored-by: David Matos <david@track32.nl> Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> Co-authored-by: Oscar Gustafsson <oscar.gustafsson@gmail.com>
1 parent b993b5a commit bb3519d

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

tutorials/provisional/mosaic.py

+20-4
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def identify_axes(ax_dict, fontsize=48):
105105
# String short-hand
106106
# =================
107107
#
108-
# By restricting our axes labels to single characters we can use Using we can
108+
# By restricting our axes labels to single characters we can
109109
# "draw" the Axes we want as "ASCII art". The following
110110

111111

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

126+
###############################################################################
127+
# Alternatively, you can use the more compact string notation
128+
mosaic = "AB;CD"
129+
130+
###############################################################################
131+
# will give you the same composition, where the ``";"`` is used
132+
# as the row separator instead of newline.
133+
134+
fig = plt.figure(constrained_layout=True)
135+
ax_dict = fig.subplot_mosaic(mosaic)
136+
identify_axes(ax_dict)
126137

127138
###############################################################################
139+
# Axes spanning multiple rows/columns
140+
# ===================================
141+
#
128142
# Something we can do with `.Figure.subplot_mosaic` that you can not
129143
# do with `.Figure.subplots` is specify that an Axes should span
130144
# several rows or columns.
131-
#
132-
# If we want to re-arrange our four Axes to have C be a horizontal
133-
# span on the bottom and D be a vertical span on the right we would do
145+
146+
147+
###############################################################################
148+
# If we want to re-arrange our four Axes to have ``"C"`` be a horizontal
149+
# span on the bottom and ``"D"`` be a vertical span on the right we would do
134150

135151
axd = plt.figure(constrained_layout=True).subplot_mosaic(
136152
"""

0 commit comments

Comments
 (0)