From de7d93f0b1c5933f4e15c087a09a64e07cb3d86a Mon Sep 17 00:00:00 2001 From: David Matos Date: Sat, 7 May 2022 21:05:36 +0200 Subject: [PATCH 1/2] docs: add subplot-mosaic string compact notation --- tutorials/provisional/mosaic.py | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/tutorials/provisional/mosaic.py b/tutorials/provisional/mosaic.py index 9aa06c9520e1..e40497ef1f9e 100644 --- a/tutorials/provisional/mosaic.py +++ b/tutorials/provisional/mosaic.py @@ -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 @@ -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 separator instead. + +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( """ From 34b0a0c987dcfd8e574bbc0116cb802c0817cef1 Mon Sep 17 00:00:00 2001 From: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> Date: Sun, 8 May 2022 19:50:00 +0200 Subject: [PATCH 2/2] Update tutorials/provisional/mosaic.py Co-authored-by: Oscar Gustafsson --- tutorials/provisional/mosaic.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/provisional/mosaic.py b/tutorials/provisional/mosaic.py index e40497ef1f9e..05623e852ed7 100644 --- a/tutorials/provisional/mosaic.py +++ b/tutorials/provisional/mosaic.py @@ -129,7 +129,7 @@ def identify_axes(ax_dict, fontsize=48): ############################################################################### # will give you the same composition, where the ``";"`` is used -# as the separator instead. +# as the row separator instead of newline. fig = plt.figure(constrained_layout=True) ax_dict = fig.subplot_mosaic(mosaic)