LukasLang/ PlotGridDoc

Extra examples for the resource function PlotGrid

Contributed by: Lukas Lang

This paclet contains extra examples for the resource function PlotGrid.

Installation Instructions

To install this paclet in your Wolfram Language environment, evaluate this code:
PacletInstall["LukasLang/PlotGridDoc"]

Details

See ResourceFunction["PlotGrid"] for the actual function.
This paclet exists only to contain examples for ResourceFunction["PlotGrid"] in order to reduce the size of the resource function notebook.
This paclet does not contain any functionality, and exists solely to hold the documentation.

Examples

Basic Examples (4) 

Create two plots sharing the y axis:

In[1]:=
ResourceFunction["PlotGrid"][
 {
  {
   Plot[x, {x, 0, 1}, Frame -> True],
   Plot[x^2, {x, 0, 1}, Frame -> True]
   }
  }
 ]
Out[1]=

Create two plots stacked vertically:

In[2]:=
ResourceFunction["PlotGrid"][
 {
  {Plot[x, {x, 0, 1}, Frame -> True]},
  {Plot[x^2, {x, 0, 1}, Frame -> True]}
  }
 ]
Out[2]=

Specify a label for the shared axes:

In[3]:=
ResourceFunction["PlotGrid"][
 {
  {Plot[x, {x, 0, 1}, Frame -> True]},
  {Plot[x^2, {x, 0, 1}, Frame -> True]}
  },
 FrameLabel -> {"x axis", "y axis"}
 ]
Out[3]=

The legends of individual plots are combined:

In[4]:=
ResourceFunction["PlotGrid"][
 {
  {
   Plot[
    {x, x^3},
    {x, 0, 1},
    Frame -> True,
    PlotLegends -> "Expressions"
    ]
   },
  {
   Plot[
    {x^2, x^4},
    {x, 0, 1},
    Frame -> True,
    PlotLegends -> "Expressions"
    ]
   }
  },
 FrameLabel -> {"x-axis", "y-axis"}
 ]
Out[4]=

Scope (5) 

Make a 2×2 grid of plots:

In[5]:=
ResourceFunction["PlotGrid"][
 {
  {
   Plot[Sin[x], {x, -\[Pi], \[Pi]}, Frame -> True],
   Plot[Cos[x], {x, -\[Pi], \[Pi]}, Frame -> True]
   },
  {
   Plot[Sin[x]^2, {x, -\[Pi], \[Pi]}, Frame -> True],
   Plot[Cos[x]^2, {x, -\[Pi], \[Pi]}, Frame -> True]
   }
  }
 ]
Out[5]=

Omit one plot, creating an L-shaped grid:

In[6]:=
ResourceFunction["PlotGrid"][
 {
  {
   Plot[Sin[x], {x, -\[Pi], \[Pi]}, Frame -> True],
   Plot[Cos[x], {x, -\[Pi], \[Pi]}, Frame -> True]
   },
  {Plot[Sin[x]^2, {x, -\[Pi], \[Pi]}, Frame -> True], Null}
  }
 ]
Out[6]=

Make the bottom plot span over both columns:

In[7]:=
ResourceFunction["PlotGrid"][
 {
  {
   Plot[Sin[x], {x, -\[Pi], \[Pi]}, Frame -> True],
   Plot[Cos[x], {x, -\[Pi], \[Pi]}, Frame -> True]
   },
  {Plot[Sin[x]^2, {x, -\[Pi], \[Pi]}, Frame -> True], SpanFromLeft}
  },
 Spacings -> 30
 ]
Out[7]=

Label the individual plots:

In[8]:=
ResourceFunction["PlotGrid"][
 {
  {
   Plot[Sin[x], {x, -\[Pi], \[Pi]}, Frame -> True],
   Plot[Cos[x], {x, -\[Pi], \[Pi]}, Frame -> True]
   },
  {Plot[Sin[x]^2, {x, -\[Pi], \[Pi]}, Frame -> True], SpanFromLeft}
  },
 Spacings -> 30,
 PlotLabels -> Row -> Style["a)", 20]
 ]
Out[8]=

If the legends are inside a plot, they are not moved:

In[9]:=
ResourceFunction["PlotGrid"][
 {
  {
   Plot[
    {x, x^3},
    {x, 0, 1},
    Frame -> True,
    PlotLegends -> Placed["Expressions", {Left, Top}]
    ]
   },
  {
   Plot[
    {x^2, x^4},
    {x, 0, 1},
    Frame -> True,
    PlotLegends -> Placed["Expressions", {Left, Top}]
    ]
   }
  },
 FrameLabel -> {"x-axis", "y-axis"}
 ]
Out[9]=

Options (65) 

AspectRatio (8) 

With the default setting AspectRatioAutomatic, the aspect ratio of the resulting grid is based on a combination of the ItemSize setting and the AspectRatio settings of the individual plots:

In[10]:=
ResourceFunction["PlotGrid"][
 {
  {
   Plot[Sin[x], {x, -\[Pi], \[Pi]}, Frame -> True],
   Plot[Cos[x], {x, -\[Pi], \[Pi]}, Frame -> True]
   },
  {
   Plot[Sin[x]^2, {x, -\[Pi], \[Pi]}, Frame -> True],
   Plot[Cos[x]^2, {x, -\[Pi], \[Pi]}, Frame -> True]
   }
  },
 Spacings -> Scaled[0.1]
 ]
Out[10]=

Changing the AspectRatio of the plots changes the resulting aspect ratio:

In[11]:=
ResourceFunction["PlotGrid"][
 {
  {
   Plot[Sin[x], {x, -\[Pi], \[Pi]}, Frame -> True],
   Plot[Cos[x], {x, -\[Pi], \[Pi]}, Frame -> True, AspectRatio -> 3]
   },
  {
   Plot[Sin[x]^2, {x, -\[Pi], \[Pi]}, Frame -> True],
   Plot[Cos[x]^2, {x, -\[Pi], \[Pi]}, Frame -> True]
   }
  },
 Spacings -> Scaled[0.1]
 ]
Out[11]=

Changing the ItemSize setting affects the aspect ratio:

In[12]:=
ResourceFunction["PlotGrid"][
 {
  {
   Plot[Sin[x], {x, -\[Pi], \[Pi]}, Frame -> True],
   Plot[Cos[x], {x, -\[Pi], \[Pi]}, Frame -> True]
   },
  {
   Plot[Sin[x]^2, {x, -\[Pi], \[Pi]}, Frame -> True],
   Plot[Cos[x]^2, {x, -\[Pi], \[Pi]}, Frame -> True]
   }
  },
 Spacings -> Scaled[0.1],
 ItemSize -> {2, 1}
 ]
Out[12]=

Base the aspect ratio only on the aspect ratios of the individual plots:

In[13]:=
ResourceFunction["PlotGrid"][
 {
  {
   Plot[Sin[x], {x, -\[Pi], \[Pi]}, Frame -> True],
   Plot[Cos[x], {x, -\[Pi], \[Pi]}, Frame -> True]
   },
  {
   Plot[Sin[x]^2, {x, -\[Pi], \[Pi]}, Frame -> True],
   Plot[Cos[x]^2, {x, -\[Pi], \[Pi]}, Frame -> True]
   }
  },
 Spacings -> Scaled[0.1],
 ItemSize -> {2, 1},
 AspectRatio -> GeometricMean
 ]
Out[13]=

Target a specific aspect ratio:

In[14]:=
ResourceFunction["PlotGrid"][
 {
  {
   Plot[Sin[x], {x, -\[Pi], \[Pi]}, Frame -> True],
   Plot[Cos[x], {x, -\[Pi], \[Pi]}, Frame -> True]
   },
  {
   Plot[Sin[x]^2, {x, -\[Pi], \[Pi]}, Frame -> True],
   Plot[Cos[x]^2, {x, -\[Pi], \[Pi]}, Frame -> True]
   }
  },
 Spacings -> Scaled[0.1],
 ItemSize -> {2, 1},
 AspectRatio -> 1
 ]
Out[14]=

Make it so the bottom left plot effectively has AspectRatioAutomatic, so that the circle is really a circle:

In[15]:=
ResourceFunction["PlotGrid"][
 {
  {
   Plot[Sin[x], {x, -\[Pi], \[Pi]}, Frame -> True],
   Plot[Sin[x]^2, {x, -\[Pi], \[Pi]}, Frame -> True]
   },
  {
   Plot[Cos[x], {x, -\[Pi], \[Pi]}, Frame -> True, Epilog -> {Red, Circle[]}],
   Plot[Cos[x]^2, {x, -\[Pi], \[Pi]}, Frame -> True]
   }
  },
 Spacings -> Scaled[0.1],
 AspectRatio -> {2, 1} -> Automatic
 ]
Out[15]=

Trying to make all plots have AspectRatioAutomatic is not always possible:

In[16]:=
ResourceFunction["PlotGrid"][
 {
  {
   Plot[Sin[x], {x, -\[Pi], \[Pi]}, Frame -> True],
   Plot[Sin[x]^2, {x, -\[Pi], \[Pi]}, Frame -> True]
   },
  {
   Plot[Cos[x], {x, -\[Pi], \[Pi]}, Frame -> True, Epilog -> {Red, Circle[]}],
   Plot[Cos[x]^2, {x, -\[Pi], \[Pi]}, Frame -> True]
   }
  },
 Spacings -> Scaled[0.1],
 AspectRatio -> All -> Automatic
 ]
Out[16]=

Equalizing the PlotRange settings will usually resolve the problem:

In[17]:=
ResourceFunction["PlotGrid"][
 {
  {
   Plot[Sin[x], {x, -\[Pi], \[Pi]}, Frame -> True],
   Plot[Sin[x]^2, {x, -\[Pi], \[Pi]}, Frame -> True]
   },
  {
   Plot[Cos[x], {x, -\[Pi], \[Pi]}, Frame -> True, Epilog -> {Red, Circle[]}],
   Plot[Cos[x]^2, {x, -\[Pi], \[Pi]}, Frame -> True]
   }
  },
 Spacings -> Scaled[0.1],
 AspectRatio -> All -> Automatic,
 PlotRange -> Max
 ]
Out[17]=

Another possibility is to only apply the aspect ratio target to as many plots as possible:

In[18]:=
ResourceFunction["PlotGrid"][
 {
  {
   Plot[Sin[x], {x, -\[Pi], \[Pi]}, Frame -> True],
   Plot[Sin[x]^2, {x, -\[Pi], \[Pi]}, Frame -> True]
   },
  {
   Plot[Cos[x], {x, -\[Pi], \[Pi]}, Frame -> True, Epilog -> {Red, Circle[]}],
   Plot[Cos[x]^2, {x, -\[Pi], \[Pi]}, Frame -> True]
   }
  },
 Spacings -> Scaled[0.1],
 AspectRatio -> Automatic -> Automatic
 ]
Out[18]=

Only rows/columns with ItemSize set to Automatic will be resized to hit the aspect ratio targets:

In[19]:=
ResourceFunction["PlotGrid"][
 {
  {
   Plot[Sin[x], {x, -\[Pi], \[Pi]}, Frame -> True],
   Plot[Cos[x], {x, -\[Pi], \[Pi]}, Frame -> True],
   Plot[Sinc[x], {x, -\[Pi], \[Pi]}, Frame -> True]
   },
  {
   Plot[Sin[x]^2, {x, -\[Pi], \[Pi]}, Frame -> True],
   Plot[Cos[x]^2, {x, -\[Pi], \[Pi]}, Frame -> True],
   Plot[Sinc[x]^2, {x, -\[Pi], \[Pi]}, Frame -> True]
   }
  },
 Spacings -> Scaled[0.1],
 ItemSize -> {{2, 1, 1}, Automatic},
 AspectRatio -> {{1, 1} -> 1, {2, 2} -> 1}
 ]
Out[19]=

Use a Frame[] type wrapper to specify the target aspect ratio for the plot with the circle, and specify a target for the overall aspect ratio:

In[20]:=
ResourceFunction["PlotGrid"][
 {
  {
   Plot[Sin[x], {x, -\[Pi], \[Pi]}, Frame -> True],
   Plot[Sin[x]^2, {x, -\[Pi], \[Pi]}, Frame -> True]
   },
  {
   Frame[
    Plot[Cos[x], {x, -\[Pi], \[Pi]}, Frame -> True, Epilog -> {Red, Circle[]}],
    AspectRatio -> Automatic
    ],
   Plot[Cos[x]^2, {x, -\[Pi], \[Pi]}, Frame -> True]
   }
  },
 Spacings -> Scaled[0.1],
 AspectRatio -> 1
 ]
Out[20]=

Use a mixture of different target aspect ratios and specify the overall aspect ratio of the grid:

In[21]:=
ResourceFunction["PlotGrid"][
 {
  {
   Plot[Sin[x], {x, -\[Pi], \[Pi]}, Frame -> True],
   Plot[Sin[x]^2, {x, -\[Pi], \[Pi]}, Frame -> True]
   },
  {
   Plot[Cos[x], {x, -\[Pi], \[Pi]}, Frame -> True, Epilog -> {Red, Circle[]}],
   Plot[Cos[x]^2, {x, -\[Pi], \[Pi]}, Frame -> True]
   }
  },
 Spacings -> Scaled[0.1],
 AspectRatio -> {1, {1, 1} -> Inherited, {2, 2} -> GoldenRatio}
 ]
Out[21]=

FrameLabel (2) 

Labels specified by FrameLabel are centered with respect to the full plot grid:

In[22]:=
ResourceFunction["PlotGrid"][
 {
  {
   Plot[Sin[x], {x, -\[Pi], \[Pi]}, Frame -> True],
   Plot[Cos[x], {x, -\[Pi], \[Pi]}, Frame -> True]
   }
  },
 FrameLabel -> {"x axis", "y axis"}
 ]
Out[22]=

Label both individual frame axes and the whole group:

In[23]:=
ResourceFunction["PlotGrid"][
 {
  {
   Plot[
    x, {x, 0, 1}, Frame -> True, FrameLabel -> {None, "y-axis 1"}
    ]
   },
  {
   Plot[
    x^2,
    {x, 0, 1},
    Frame -> True,
    FrameLabel -> {None, "y-axis 2"}
    ]
   }
  },
 FrameLabel -> {None, "y-axes"}
 ]
Out[23]=

FrameStyle (2) 

The setting for FrameStyle affects the frame labels shared by all plots:

In[24]:=
ResourceFunction["PlotGrid"][
 {
  {
   Plot[
    x, {x, 0, 1}, Frame -> True, FrameLabel -> {None, "y-axis 1"}
    ]
   },
  {
   Plot[
    x^2,
    {x, 0, 1},
    Frame -> True,
    FrameLabel -> {None, "y-axis 2"}
    ]
   }
  },
 FrameLabel -> {None, "y-axes"},
 FrameStyle -> FontSize -> 16
 ]
Out[24]=

With the default setting FrameStyleAutomatic, the style is inherited from the first plot:

In[25]:=
ResourceFunction["PlotGrid"][
 {
  {
   Plot[
    x,
    {x, 0, 1},
    Frame -> True,
    FrameLabel -> {None, "y-axis 1"},
    FrameStyle -> Red
    ]
   },
  {
   Plot[
    x^2,
    {x, 0, 1},
    Frame -> True,
    FrameLabel -> {None, "y-axis 2"},
    FrameStyle -> Red
    ]
   }
  },
 FrameLabel -> {None, "y-axes"}
 ]
Out[25]=

ItemSize (5) 

With the default setting ItemSizeAutomatic, all rows and columns have the same size:

In[26]:=
ResourceFunction["PlotGrid"][
 Table[
  Graphics[
   Text[{i, j}],
   PlotRange -> {{-j, j}, {-i, i}},
   Frame -> True
   ],
  {i, 3},
  {j, 3}
  ]
 ]
Out[26]=

Make the middle row twice as high:

In[27]:=
ResourceFunction["PlotGrid"][
 Table[
  Graphics[
   Text[{i, j}],
   PlotRange -> 1.2 {{-j, j}, {-i, i}},
   Frame -> True
   ],
  {i, 3},
  {j, 3}
  ],
 ItemSize -> {Automatic, {2 -> 2}}
 ]
Out[27]=

Size the rows and columns according to the plot ranges:

In[28]:=
ResourceFunction["PlotGrid"][
 Table[
  Graphics[
   Text[{i, j}],
   PlotRange -> 1.2 {{-j, j}, {-i, i}},
   Frame -> True
   ],
  {i, 3},
  {j, 3}
  ],
 ItemSize -> Scaled
 ]
Out[28]=

Size the rows and columns according to the plot ranges, but make the third column half as wide:

In[29]:=
ResourceFunction["PlotGrid"][
 Table[
  Graphics[
   Text[{i, j}],
   PlotRange -> 1.2 {{-j, j}, {-i, i}},
   Frame -> True
   ],
  {i, 3},
  {j, 3}
  ],
 ItemSize -> {{{Scaled}, Scaled[0.5]}, Scaled}
 ]
Out[29]=

Make the first row and column 100 printers points big:

In[30]:=
ResourceFunction["PlotGrid"][
 Table[
  Graphics[
   Text[{i, j}],
   PlotRange -> 1.2 {{-j, j}, {-i, i}},
   Frame -> True
   ],
  {i, 3},
  {j, 3}
  ],
 ItemSize -> {{Offset[100]}, {Offset[100]}}
 ]
Out[30]=

The remaining space is dynamically filled by the remaining rows and columns:

In[31]:=
Manipulate[
 ResourceFunction["PlotGrid"][
  Table[
   Graphics[
    Text[{i, j}],
    PlotRange -> 1.2 {{-j, j}, {-i, i}},
    Frame -> True
    ],
   {i, 3},
   {j, 3}
   ],
  ItemSize -> {{Offset[100]}, {Offset[100]}},
  ImageSize -> Dynamic[size],
  PerformanceGoal -> "Speed"
  ],
 {size, 200, 600}
 ]
Out[31]=

Spacings (5) 

With the default setting SpacingsNone, no space is left between rows and columns:

In[32]:=
ResourceFunction["PlotGrid"][
 Table[
  Graphics[
   Text[{i, j}],
   PlotRange -> 1.2 {{-j, j}, {-i, i}},
   Frame -> True
   ],
  {i, 3},
  {j, 3}
  ]
 ]
Out[32]=

Separate plots by 30 printers points:

In[33]:=
ResourceFunction["PlotGrid"][
 Table[
  Graphics[
   Text[{i, j}],
   PlotRange -> 1.2 {{-j, j}, {-i, i}},
   Frame -> True
   ],
  {i, 3},
  {j, 3}
  ],
 Spacings -> 30
 ]
Out[33]=

Separate plots by 10% of the total plot grid width:

In[34]:=
ResourceFunction["PlotGrid"][
 Table[
  Graphics[
   Text[{i, j}],
   PlotRange -> 1.2 {{-j, j}, {-i, i}},
   Frame -> True
   ],
  {i, 3},
  {j, 3}
  ],
 Spacings -> Scaled[0.1]
 ]
Out[34]=

Only insert space between rows:

In[35]:=
ResourceFunction["PlotGrid"][
 Table[
  Graphics[
   Text[{i, j}],
   PlotRange -> 1.2 {{-j, j}, {-i, i}},
   Frame -> True
   ],
  {i, 3},
  {j, 3}
  ],
 Spacings -> {None, Scaled[0.1]}
 ]
Out[35]=

With "ShowFrameLabels"Full, frame labels and ticks are shown if there is a gap:

In[36]:=
ResourceFunction["PlotGrid"][
 Table[
  Graphics[
   Text[{i, j}],
   PlotRange -> 1.2 {{-j, j}, {-i, i}},
   Frame -> True
   ],
  {i, 3},
  {j, 3}
  ],
 Spacings -> {None, Scaled[0.1]},
 "ShowFrameLabels" -> Full
 ]
Out[36]=

PlotRange (5) 

With the default setting PlotRangeInherited, the plot ranges of the plots are left unmodified:

In[37]:=
ResourceFunction["PlotGrid"][
 {
  {
   Plot[Sin[x], {x, -\[Pi], \[Pi]}, Frame -> True],
   Plot[2 Sin[x], {x, -2 \[Pi], 2 \[Pi]}, Frame -> True]
   },
  {
   Plot[1.5 Cos[x], {x, -2 \[Pi], 2 \[Pi]}, Frame -> True],
   Plot[Sin[x], {x, -0 \[Pi], 3 \[Pi]}, Frame -> True]
   }
  }
 ]
Out[37]=

Ensure that the plot ranges of the plots are consistent while showing all data:

In[38]:=
ResourceFunction["PlotGrid"][
 {
  {
   Plot[Sin[x], {x, -\[Pi], \[Pi]}, Frame -> True],
   Plot[2 Sin[x], {x, -2 \[Pi], 2 \[Pi]}, Frame -> True]
   },
  {
   Plot[1.5 Cos[x], {x, -2 \[Pi], 2 \[Pi]}, Frame -> True],
   Plot[Sin[x], {x, -0 \[Pi], 3 \[Pi]}, Frame -> True]
   }
  },
 PlotRange -> Max
 ]
Out[38]=

Use a reduced plot range to ensure all plots are filled out:

In[39]:=
ResourceFunction["PlotGrid"][
 {
  {
   Plot[Sin[x], {x, -\[Pi], \[Pi]}, Frame -> True],
   Plot[2 Sin[x], {x, -2 \[Pi], 2 \[Pi]}, Frame -> True]
   },
  {
   Plot[1.5 Cos[x], {x, -2 \[Pi], 2 \[Pi]}, Frame -> True],
   Plot[Sin[x], {x, -0 \[Pi], 3 \[Pi]}, Frame -> True]
   }
  },
 PlotRange -> Min
 ]
Out[39]=

Show everything in the vertical range, but crop the horizontal range to the common part of the ranges:

In[40]:=
ResourceFunction["PlotGrid"][
 {
  {
   Plot[Sin[x], {x, -\[Pi], \[Pi]}, Frame -> True],
   Plot[2 Sin[x], {x, -2 \[Pi], 2 \[Pi]}, Frame -> True]
   },
  {
   Plot[1.5 Cos[x], {x, -2 \[Pi], 2 \[Pi]}, Frame -> True],
   Plot[Sin[x], {x, -0 \[Pi], 3 \[Pi]}, Frame -> True]
   }
  },
 PlotRange -> {Min, Max}
 ]
Out[40]=

Use explicit settings for the plot ranges, using Directive instead of {} to prevent ambiguity:

In[41]:=
ResourceFunction["PlotGrid"][
 {
  {
   Plot[Sin[x], {x, -\[Pi], \[Pi]}, Frame -> True],
   Plot[2 Sin[x], {x, -2 \[Pi], 2 \[Pi]}, Frame -> True]
   },
  {
   Plot[1.5 Cos[x], {x, -2 \[Pi], 2 \[Pi]}, Frame -> True],
   Plot[Sin[x], {x, -0 \[Pi], 3 \[Pi]}, Frame -> True]
   }
  },
 PlotRange -> {
   {Directive[-3, 2], Directive[2, 6]},
   {Directive[-2.5, 2.5], Directive[-1, 3]}
   }
 ]
Out[41]=

PlotLabels (8) 

With the default setting PlotLabelsNone, the plots are not labeled:

In[42]:=
ResourceFunction["PlotGrid"][
 {
  {
   Plot[Sin[x], {x, -\[Pi], \[Pi]}, Frame -> True],
   Plot[Cos[x], {x, -\[Pi], \[Pi]}, Frame -> True]
   },
  {Plot[Sin[x]^2, {x, -\[Pi], \[Pi]}, Frame -> True], SpanFromLeft}
  },
 Spacings -> 35
 ]
Out[42]=

Label the plots columns first using a), b), …:

In[43]:=
ResourceFunction["PlotGrid"][
 {
  {
   Plot[Sin[x], {x, -\[Pi], \[Pi]}, Frame -> True],
   Plot[Cos[x], {x, -\[Pi], \[Pi]}, Frame -> True]
   },
  {Plot[Sin[x]^2, {x, -\[Pi], \[Pi]}, Frame -> True], SpanFromLeft}
  },
 Spacings -> 35,
 PlotLabels -> Automatic -> "a)"
 ]
Out[43]=

Apply styling to the labels and use sequential numbers:

In[44]:=
ResourceFunction["PlotGrid"][
 {
  {
   Plot[Sin[x], {x, -\[Pi], \[Pi]}, Frame -> True],
   Plot[Cos[x], {x, -\[Pi], \[Pi]}, Frame -> True]
   },
  {Plot[Sin[x]^2, {x, -\[Pi], \[Pi]}, Frame -> True], SpanFromLeft}
  },
 Spacings -> 35,
 PlotLabels -> Automatic -> Style["1.", 20, Black]
 ]
Out[44]=

Place the labels outside the plots and number rows first:

In[45]:=
ResourceFunction["PlotGrid"][
 {
  {
   Plot[Sin[x], {x, -\[Pi], \[Pi]}, Frame -> True],
   Plot[Cos[x], {x, -\[Pi], \[Pi]}, Frame -> True]
   },
  {Plot[Sin[x]^2, {x, -\[Pi], \[Pi]}, Frame -> True], SpanFromLeft}
  },
 Spacings -> 35,
 PlotLabels -> Placed[Row -> "i)", {Left, Above}]
 ]
Out[45]=

The base style of the labels is affected by LabelStyle:

In[46]:=
ResourceFunction["PlotGrid"][
 {
  {
   Plot[Sin[x], {x, -\[Pi], \[Pi]}, Frame -> True],
   Plot[Cos[x], {x, -\[Pi], \[Pi]}, Frame -> True]
   },
  {Plot[Sin[x]^2, {x, -\[Pi], \[Pi]}, Frame -> True], SpanFromLeft}
  },
 Spacings -> 35,
 PlotLabels -> Placed[Row -> "i)", {Left, Above}],
 LabelStyle -> {Black, 15}
 ]
Out[46]=

Add an additional custom label to one of the plots using a Labeled wrapper:

In[47]:=
ResourceFunction["PlotGrid"][
 {
  {
   Labeled[
    Plot[Sin[x], {x, -\[Pi], \[Pi]}, Frame -> True],
    "A label",
    {Left, Top}
    ],
   Plot[Cos[x], {x, -\[Pi], \[Pi]}, Frame -> True]
   },
  {Plot[Sin[x]^2, {x, -\[Pi], \[Pi]}, Frame -> True], SpanFromLeft}
  },
 Spacings -> 35,
 PlotLabels -> Placed[Row -> "i)", {Left, Above}]
 ]
Out[47]=

If the same position is specified for multiple labels, overlap is automatically avoided:

In[48]:=
ResourceFunction["PlotGrid"][
 {
  {
   Labeled[
    Plot[Sin[x], {x, -\[Pi], \[Pi]}, Frame -> True],
    "A label",
    {Left, Above}
    ],
   Plot[Cos[x], {x, -\[Pi], \[Pi]}, Frame -> True]
   },
  {Plot[Sin[x]^2, {x, -\[Pi], \[Pi]}, Frame -> True], SpanFromLeft}
  },
 Spacings -> 35,
 PlotLabels -> Placed[Row -> "i)", {Left, Above}]
 ]
Out[48]=

Number plots automatically, but add an additional description to each plot:

In[49]:=
ResourceFunction["PlotGrid"][
 {
  {
   Plot[Sin[x], {x, -\[Pi], \[Pi]}, Frame -> True],
   Plot[Cos[x], {x, -\[Pi], \[Pi]}, Frame -> True]
   },
  {Plot[Sin[x]^2, {x, -\[Pi], \[Pi]}, Frame -> True], SpanFromLeft}
  },
 Spacings -> 35,
 PlotLabels -> Placed[
   {
    Row -> "(1)",
    {"Plot 1", "Plot 2", "Plot 3"},
    {{}}(* to avoid ambiguity *)
    },
   {Left, Top}
   ]
 ]
Out[49]=

LabelingFunction (4) 

With the default setting LabelingFunctionAutomatic, labels with the same position are put into a row/column, depending on the position of the labels:

In[50]:=
ResourceFunction["PlotGrid"][
 {
  {
   Plot[Sin[x], {x, -\[Pi], \[Pi]}, Frame -> True],
   Plot[Cos[x], {x, -\[Pi], \[Pi]}, Frame -> True]
   },
  {Plot[Sin[x]^2, {x, -\[Pi], \[Pi]}, Frame -> True], SpanFromLeft}
  },
 Spacings -> 30,
 PlotLabels -> {
   Placed[{"Label 1.1", "Label 1.2"}, {Left, Above}],
   Placed[{"Label 2.1", "Label 2.2"}, {After, Center}]
   }
 ]
Out[50]=

Stack all labels vertically:

In[51]:=
ResourceFunction["PlotGrid"][
 {
  {
   Plot[Sin[x], {x, -\[Pi], \[Pi]}, Frame -> True],
   Plot[Cos[x], {x, -\[Pi], \[Pi]}, Frame -> True]
   },
  {Plot[Sin[x]^2, {x, -\[Pi], \[Pi]}, Frame -> True], SpanFromLeft}
  },
 Spacings -> 30,
 PlotLabels -> {
   Placed[{"Label 1.1", "Label 1.2"}, {Left, Above}],
   Placed[{"Label 2.1", "Label 2.2"}, {After, Center}]
   },
 LabelingFunction -> Column
 ]
Out[51]=

Put frames around the labels:

In[52]:=
ResourceFunction["PlotGrid"][
 {
  {
   Plot[Sin[x], {x, -\[Pi], \[Pi]}, Frame -> True],
   Plot[Cos[x], {x, -\[Pi], \[Pi]}, Frame -> True]
   },
  {Plot[Sin[x]^2, {x, -\[Pi], \[Pi]}, Frame -> True], SpanFromLeft}
  },
 Spacings -> 30,
 PlotLabels -> {
   Placed[{"Label 1.1", "Label 1.2"}, {Left, Above}],
   Placed[{"Label 2.1", "Label 2.2"}, {After, Center}],
   "Label 3"
   },
 LabelingFunction -> (Framed[Column@#, Background -> White] &)
 ]
Out[52]=

Put frames around the labels, but preserve the automatic layout:

In[53]:=
ResourceFunction["PlotGrid"][
 {
  {
   Plot[Sin[x], {x, -\[Pi], \[Pi]}, Frame -> True],
   Plot[Cos[x], {x, -\[Pi], \[Pi]}, Frame -> True]
   },
  {Plot[Sin[x]^2, {x, -\[Pi], \[Pi]}, Frame -> True], SpanFromLeft}
  },
 Spacings -> 30,
 PlotLabels -> {
   Placed[{"Label 1.1", "Label 1.2"}, {Left, Above}],
   Placed[{"Label 2.1", "Label 2.2"}, {After, Center}],
   "Label 3"
   },
 LabelingFunction -> Automatic -> (Framed[#, Background -> White] &)
 ]
Out[53]=

Prolog & Epilog (2) 

Positions inside Prolog and Epilog can be of the form {i,j}pos to specify positions relative to the plot with index {i,j}:

In[54]:=
ResourceFunction["PlotGrid"][
 {
  {
   Plot[Sin[x], {x, -\[Pi], \[Pi]}, Frame -> True],
   Plot[Cos[x], {x, -\[Pi], \[Pi]}, Frame -> True]
   },
  {Plot[Sin[x]^2, {x, -\[Pi], \[Pi]}, Frame -> True], SpanFromLeft}
  },
 Spacings -> 35,
 Epilog -> {
   Blue, Text["A label", {1, 2} -> {2, 0.4}],
   Red, Arrow@{{1, 1} -> {\[Pi]/2, 1}, {2, 1} -> {1, Sin[1]^2}}
   }
 ]
Out[54]=

Positions can also be of type Scaled[], ImageScaled[], and Offset[]:

In[55]:=
ResourceFunction["PlotGrid"][
 {
  {
   Plot[Sin[x], {x, -\[Pi], \[Pi]}, Frame -> True],
   Plot[Cos[x], {x, -\[Pi], \[Pi]}, Frame -> True]
   },
  {Plot[Sin[x]^2, {x, -\[Pi], \[Pi]}, Frame -> True], SpanFromLeft}
  },
 Spacings -> 35,
 Epilog -> {
   EdgeForm@Black, FaceForm@None, Rectangle[{1, 1} -> ImageScaled@{0, 0}, {1, 2} -> ImageScaled@{1, 1}],
   Red, Arrow@{{1, 1} -> Scaled@{1, 0}, {2, 1} -> {1, Sin[1]^2}},
   Green, Circle[{2, 1} -> Offset[{10, -10}, Scaled@{0, 1}], Offset[10]]
   }
 ]
Out[55]=

ShowFrameLabels (6) 

With the default setting "ShowFrameLabels"Full, frame ticks and labels are shown if there is no adjacent plot or a spacing:

In[56]:=
ResourceFunction["PlotGrid"][
 Table[
  Graphics[
   Text[{i, j}],
   PlotRange -> 1.2 {{-j, j}, {-i, i}},
   Frame -> True
   ],
  {i, 3},
  {j, 3}
  ],
 Spacings -> {None, 20}
 ]
Out[56]=

Labels are shown if a plot is omitted:

In[57]:=
ResourceFunction["PlotGrid"][
 ReplacePart[
  Table[
   Graphics[
    Text[{i, j}],
    PlotRange -> 1.2 {{-j, j}, {-i, i}},
    Frame -> True
    ],
   {i, 3},
   {j, 3}
   ],
  {2, 2} -> Null
  ],
 Spacings -> {None, 20}
 ]
Out[57]=

Hide all labels unless there is no adjacent plot at all:

In[58]:=
ResourceFunction["PlotGrid"][
 Table[
  Graphics[
   Text[{i, j}],
   PlotRange -> 1.2 {{-j, j}, {-i, i}},
   Frame -> True
   ],
  {i, 3},
  {j, 3}
  ],
 Spacings -> {None, 20},
 "ShowFrameLabels" -> Automatic
 ]
Out[58]=

Show no frame labels:

In[59]:=
ResourceFunction["PlotGrid"][
 Table[
  Graphics[
   Text[{i, j}],
   PlotRange -> 1.2 {{-j, j}, {-i, i}},
   Frame -> True
   ],
  {i, 3},
  {j, 3}
  ],
 Spacings -> {None, 20},
 "ShowFrameLabels" -> None
 ]
Out[59]=

Show all frame labels:

In[60]:=
ResourceFunction["PlotGrid"][
 Table[
  Graphics[
   Text[{i, j}],
   PlotRange -> 1.2 {{-j, j}, {-i, i}},
   Frame -> True
   ],
  {i, 3},
  {j, 3}
  ],
 Spacings -> {None, 20},
 "ShowFrameLabels" -> All
 ]
Out[60]=

Hide frame labels of the center plot using a Frame[plot,]-type wrapper:

In[61]:=
ResourceFunction["PlotGrid"][
 MapAt[
  Frame[#, "ShowFrameLabels" -> None] &,
  Table[
   Graphics[
    Text[{i, j}],
    PlotRange -> 1.2 {{-j, j}, {-i, i}},
    Frame -> True
    ],
   {i, 3},
   {j, 3}
   ],
  {2, 2}
  ],
 Spacings -> {None, 20}
 ]
Out[61]=

HideOuterTickLabels (6) 

With the default setting "HideOuterTickLabels"Full, the rightmost tick label on each plot to the left of another plot is hidden if there is insufficient Spacings. Similarly, the topmost tick label on each plot below another plot is hidden:

In[62]:=
ResourceFunction["PlotGrid"][
 Table[
  Graphics[
   Text[{i, j}],
   PlotRange -> {{-j, j}, {-i, i}},
   Frame -> True
   ],
  {i, 3},
  {j, 3}
  ],
 Spacings -> {{None, 30}, {None, 30}}
 ]
Out[62]=

Hide the labels on both plots, not only the left/bottom one:

In[63]:=
ResourceFunction["PlotGrid"][
 Table[
  Graphics[
   Text[{i, j}],
   PlotRange -> {{-j, j}, {-i, i}},
   Frame -> True
   ],
  {i, 3},
  {j, 3}
  ],
 Spacings -> {{None, 30}, {None, 30}},
 "HideOuterTickLabels" -> Directive[All, Full]
 ]
Out[63]=

Also hide outer labels if there is spacing between the plots:

In[64]:=
ResourceFunction["PlotGrid"][
 Table[
  Graphics[
   Text[{i, j}],
   PlotRange -> {{-j, j}, {-i, i}},
   Frame -> True
   ],
  {i, 3},
  {j, 3}
  ],
 Spacings -> {{None, 30}, {None, 30}},
 "HideOuterTickLabels" -> Automatic
 ]
Out[64]=

Hide labels in the outer 50% of the plot range instead of the default 10 printers points. The hiding is done in the default locations, meaning only on the top rows and left columns and never on the outermost edges:

In[65]:=
ResourceFunction["PlotGrid"][
 Table[
  Graphics[
   Text[{i, j}],
   PlotRange -> {{-j, j}, {-i, i}},
   Frame -> True
   ],
  {i, 3},
  {j, 3}
  ],
 Spacings -> {{None, 30}, {None, 30}},
 "HideOuterTickLabels" -> Scaled[0.5]
 ]
Out[65]=

Do not hide any tick labels, potentially causing overlaps:

In[66]:=
ResourceFunction["PlotGrid"][
 Table[
  Graphics[
   Text[{i, j}],
   PlotRange -> {{-j, j}, {-i, i}},
   Frame -> True
   ],
  {i, 3},
  {j, 3}
  ],
 Spacings -> {None, 20},
 "HideOuterTickLabels" -> None
 ]
Out[66]=

Hide the outer ticks on the lower right plot only by specifying the setting using a Frame[plot,]-type wrapper:

In[67]:=
ResourceFunction["PlotGrid"][
 MapAt[
  Frame[#, "HideOuterTickLabels" -> {Directive[Right, All, 30], None}] &,
  Table[
   Graphics[
    Text[{i, j}],
    PlotRange -> {{-j, j}, {-i, i}},
    Frame -> True
    ],
   {i, 3},
   {j, 3}
   ],
  {3, 3}
  ],
 Spacings -> {None, 20},
 "HideOuterTickLabels" -> None
 ]
Out[67]=

MergeAxes (7) 

With the default setting "MergeAxes"False, the axes of the plots are not merged:

In[68]:=
ResourceFunction["PlotGrid"][
 {
  {
   Plot[Sin[x], {x, -\[Pi], \[Pi]}, Frame -> True, Axes -> False],
   Plot[Cos[x], {x, -\[Pi], \[Pi]}, Frame -> True]
   },
  {Plot[Sin[x]^2, {x, -\[Pi], \[Pi]}, Frame -> True, Axes -> False], SpanFromAbove}
  },
 Spacings -> 30
 ]
Out[68]=

Merge the axes of the left two plots using a zig-zag line:

In[69]:=
ResourceFunction["PlotGrid"][
 {
  {
   Plot[Sin[x], {x, -\[Pi], \[Pi]}, Frame -> True, Axes -> False],
   Plot[Cos[x], {x, -\[Pi], \[Pi]}, Frame -> True]
   },
  {Plot[Sin[x]^2, {x, -\[Pi], \[Pi]}, Frame -> True, Axes -> False], SpanFromAbove}
  },
 Spacings -> 30,
 "MergeAxes" -> {False, "ZigZag"}
 ]
Out[69]=

Use a cut-type indicator instead, and make the gap larger:

In[70]:=
ResourceFunction["PlotGrid"][
 {
  {
   Plot[Sin[x], {x, -\[Pi], \[Pi]}, Frame -> True, Axes -> False],
   Plot[Cos[x], {x, -\[Pi], \[Pi]}, Frame -> True]
   },
  {Plot[Sin[x]^2, {x, -\[Pi], \[Pi]}, Frame -> True, Axes -> False], SpanFromAbove}
  },
 Spacings -> 30,
 "MergeAxes" -> {False, "Cut" -> 30}
 ]
Out[70]=

The frame styles of both plots are inherited:

In[71]:=
ResourceFunction["PlotGrid"][
 {
  {
   Plot[Sin[x], {x, -\[Pi], \[Pi]}, Frame -> True, Axes -> False, FrameStyle -> Red],
   Plot[Cos[x], {x, -\[Pi], \[Pi]}, Frame -> True]
   },
  {Plot[Sin[x]^2, {x, -\[Pi], \[Pi]}, Frame -> True, Axes -> False, FrameStyle -> Blue], SpanFromAbove}
  },
 Spacings -> 30,
 "MergeAxes" -> {False, Directive["Wave" -> 20, 20]}
 ]
Out[71]=

Specify which axes to merge using a Frame[plot,]-type wrapper instead:

In[72]:=
ResourceFunction["PlotGrid"][
 {
  {
   Frame[
    Plot[Sin[x], {x, -\[Pi], \[Pi]}, Frame -> True, Axes -> False, FrameStyle -> Red],
    "MergeAxes" -> {False, "Dotted" -> 20}
    ],
   Plot[Cos[x], {x, -\[Pi], \[Pi]}, Frame -> True]
   },
  {Plot[Sin[x]^2, {x, -\[Pi], \[Pi]}, Frame -> True, Axes -> False, FrameStyle -> Blue], SpanFromAbove}
  },
 Spacings -> 30
 ]
Out[72]=

Use a custom merge indicator:

In[73]:=
ResourceFunction["PlotGrid"][
 {
  {
   Frame[
    Plot[Sin[x], {x, -\[Pi], \[Pi]}, Frame -> True, Axes -> False, FrameStyle -> Red],
    "MergeAxes" -> {False, {Graphics[Rectangle[{0, -1}, {0.5, 1}], PlotRange -> {{0, 1}, {-1, 1}}, PlotRangePadding -> None, AspectRatio -> Full], Automatic}}
    ],
   Plot[Cos[x], {x, -\[Pi], \[Pi]}, Frame -> True]
   },
  {Plot[Sin[x]^2, {x, -\[Pi], \[Pi]}, Frame -> True, Axes -> False, FrameStyle -> Blue], SpanFromAbove}
  },
 Spacings -> 30
 ]
Out[73]=

Use a different merge indicator on each side of the gap:

In[74]:=
ResourceFunction["PlotGrid"][
 {
  {
   Frame[
    Plot[Sin[x], {x, -\[Pi], \[Pi]}, Frame -> True, Axes -> False, FrameStyle -> Red],
    "MergeAxes" -> {
      False,
      {
       Graphics[{Arrowheads@1, Arrow@{{0, 0}, {0.5, 0}}}, PlotRange -> {{0, 1}, {-1, 1}}, PlotRangePadding -> None, AspectRatio -> Full],
       Graphics[Rectangle[{0, -1}, {0.5, 1}], PlotRange -> {{0, 1}, {-1, 1}}, PlotRangePadding -> None, AspectRatio -> Full]
       }
      }
    ],
   Plot[Cos[x], {x, -\[Pi], \[Pi]}, Frame -> True]
   },
  {Plot[Sin[x]^2, {x, -\[Pi], \[Pi]}, Frame -> True, Axes -> False, FrameStyle -> Blue], SpanFromAbove}
  },
 Spacings -> 30
 ]
Out[74]=

PerformanceGoal (1) 

Setting PerformanceGoal to "Speed" can drastically improve the performance when resizing the plot grid due to an issue in the front end related to custom ticks:

In[75]:=
Manipulate[
 ResourceFunction["PlotGrid"][
  Table[
   Graphics[
    Text[{i, j}],
    PlotRange -> 1.2 {{-j, j}, {-i, i}},
    Frame -> True
    ],
   {i, 3},
   {j, 3}
   ],
  ItemSize -> {{Offset[100]}, {Offset[100]}},
  ImageSize -> Dynamic[size],
  PerformanceGoal -> perfGoal
  ],
 {size, 200, 600},
 {perfGoal, {"Speed", "Quality"}}
 ]
Out[75]=

Method (4) 

With the default setting "FixFrameTicks"True, the tick length is corrected to appear as expected:

In[76]:=
ResourceFunction["PlotGrid"][
 {{
   DateListPlot[{1, 1, 2, 3, 5, 8, 11}, {2000, 8}],
   DateListPlot[{1, 1, 2, 3, 5, 8, 11}, {2000, 8}]
   }}
 ]
Out[76]=

Turning the fix off might yield unexpected results:

In[77]:=
ResourceFunction["PlotGrid"][
 {{
   DateListPlot[{1, 1, 2, 3, 5, 8, 11}, {2000, 8}],
   DateListPlot[{1, 1, 2, 3, 5, 8, 11}, {2000, 8}]
   }},
 Method -> {"FixFrameTicks" -> False}
 ]
Out[77]=

With the default setting "AllCustomTicks"Automatic, ticks are ensured to be uniform, even if this means differences to the default tick positioning:

In[78]:=
plots = {{
   Plot[x, {x, 0, 3}, Frame -> True],
   Plot[x, {x, 0, 3}, Frame -> True]
   }}
Out[78]=
In[79]:=
ResourceFunction["PlotGrid"][plots]
Out[79]=

Use "AllCustomTicks"False to use custom ticks only where necessary, e.g. to hide tick labels selectively:

In[80]:=
ResourceFunction["PlotGrid"][
 plots,
 Method -> {"AllCustomTicks" -> False}
 ]
Out[80]=

Possible Issues (8) 

PlotGrid assumes that plots have compatible plot ranges:

In[81]:=
ResourceFunction["PlotGrid"][
 {{
   Plot[x, {x, 0, 3}, Frame -> True],
   Plot[x^2, {x, 0, 3}, Frame -> True]
   }}
 ]
Out[81]=

Use the option PlotRange to enforce consistent plot ranges:

In[82]:=
ResourceFunction["PlotGrid"][
 {{
   Plot[x, {x, 0, 3}, Frame -> True],
   Plot[x^2, {x, 0, 3}, Frame -> True]
   }},
 PlotRange -> Max
 ]
Out[82]=

Tick labels are hidden based on the size the grid is generated with; therefore, changing it later might lead to unexpected results:

In[83]:=
Show[
 ResourceFunction["PlotGrid"][
  {{
    Plot[x, {x, 0, 2.65}, Frame -> True],
    Plot[x, {x, 0, 3}, Frame -> True]
    }}
  ],
 ImageSize -> 250
 ]
Out[83]=

Specify the size directly instead:

In[84]:=
ResourceFunction["PlotGrid"][
 {
  {
   Plot[x, {x, 0, 2.65}, Frame -> True],
   Plot[x, {x, 0, 3}, Frame -> True]
   }
  },
 ImageSize -> 250
 ]
Out[84]=

The ticks might sometimes be changed by PlotGrid:

In[85]:=
plots = {{
   Plot[x, {x, 0, 3}, Frame -> True],
   Plot[x, {x, 0, 3}, Frame -> True]
   }}
Out[85]=
In[86]:=
ResourceFunction["PlotGrid"][plots]
Out[86]=

To recover the original ticks, disable both "HideOuterTickLabels" and "AllCustomTicks":

In[87]:=
ResourceFunction["PlotGrid"][
 plots,
 "HideOuterTickLabels" -> None,
 Method -> {"AllCustomTicks" -> False}
 ]
Out[87]=

Invalid specifications for spanning plots lead to leftover span indicators:

In[88]:=
ResourceFunction["PlotGrid"][
 {
  {
   Plot[Sin[x], {x, -\[Pi], \[Pi]}, Frame -> True],
   SpanFromAbove
   },
  {
   SpanFromLeft,
   SpanFromBoth
   }
  },
 Spacings -> 30
 ]
Out[88]=

Some label specifications are potentially ambiguous and might be interpreted in an unexpected way:

In[89]:=
ResourceFunction["PlotGrid"][
 {
  {
   Plot[Sin[x], {x, -\[Pi], \[Pi]}, Frame -> True],
   Plot[Cos[x], {x, -\[Pi], \[Pi]}, Frame -> True]
   },
  {Plot[Sin[x]^2, {x, -\[Pi], \[Pi]}, Frame -> True], SpanFromLeft}
  },
 Spacings -> 35,
 PlotLabels -> Placed[
   {
    Row -> "(1)",
    {"Plot 1", "Plot 2", "Plot 3"}
    },
   {Left, Top}
   ]
 ]
Out[89]=

Add an empty two-level label specification to ensure the specification is interpreted as a list of several top-level label lists:

In[90]:=
ResourceFunction["PlotGrid"][
 {
  {
   Plot[Sin[x], {x, -\[Pi], \[Pi]}, Frame -> True],
   Plot[Cos[x], {x, -\[Pi], \[Pi]}, Frame -> True]
   },
  {Plot[Sin[x]^2, {x, -\[Pi], \[Pi]}, Frame -> True], SpanFromLeft}
  },
 Spacings -> 35,
 PlotLabels -> Placed[
   {
    Row -> "(1)",
    {"Plot 1", "Plot 2", "Plot 3"},
    {{}}(* to avoid ambiguity *)
    },
   {Left, Top}
   ]
 ]
Out[90]=

Some settings for AspectRatio will lead to unresolvable constraints on the sizes of the rows and columns:

In[91]:=
ResourceFunction["PlotGrid"][
 {
  {
   Plot[Sin[x], {x, -\[Pi], \[Pi]}, Frame -> True],
   Plot[Cos[x], {x, -\[Pi], \[Pi]}, Frame -> True]
   },
  {
   Plot[Sin[x]^2, {x, -\[Pi], \[Pi]}, Frame -> True],
   Plot[Cos[x]^2, {x, -\[Pi], \[Pi]}, Frame -> True]
   }
  },
 Spacings -> Scaled[0.1],
 AspectRatio -> {{1, 1} -> 2, {1, 2} -> 1, {2, 1} -> 2, {2, 2} -> 0.5}
 ]
Out[91]=

Remove some of the AspectRatio targets:

In[92]:=
ResourceFunction["PlotGrid"][
 {
  {
   Plot[Sin[x], {x, -\[Pi], \[Pi]}, Frame -> True],
   Plot[Cos[x], {x, -\[Pi], \[Pi]}, Frame -> True]
   },
  {
   Plot[Sin[x]^2, {x, -\[Pi], \[Pi]}, Frame -> True],
   Plot[Cos[x]^2, {x, -\[Pi], \[Pi]}, Frame -> True]
   }
  },
 Spacings -> Scaled[0.1],
 AspectRatio -> {{1, 1} -> 2, {1, 2} -> 1, {2, 2} -> 0.5}
 ]
Out[92]=

Targeting AspectRatio settings for individual plots is not supported when Offset type specifications are used:

In[93]:=
ResourceFunction["PlotGrid"][
 {
  {
   Plot[Sin[x], {x, -\[Pi], \[Pi]}, Frame -> True],
   Plot[Cos[x], {x, -\[Pi], \[Pi]}, Frame -> True]
   },
  {
   Plot[Sin[x]^2, {x, -\[Pi], \[Pi]}, Frame -> True],
   Plot[Cos[x]^2, {x, -\[Pi], \[Pi]}, Frame -> True]
   }
  },
 Spacings -> 35,
 AspectRatio -> {1, 1} -> 2
 ]
Out[93]=

Use Scaled[] type Spacings instead:

In[94]:=
ResourceFunction["PlotGrid"][
 {
  {
   Plot[Sin[x], {x, -\[Pi], \[Pi]}, Frame -> True],
   Plot[Cos[x], {x, -\[Pi], \[Pi]}, Frame -> True]
   },
  {
   Plot[Sin[x]^2, {x, -\[Pi], \[Pi]}, Frame -> True],
   Plot[Cos[x]^2, {x, -\[Pi], \[Pi]}, Frame -> True]
   }
  },
 Spacings -> Scaled[0.1],
 AspectRatio -> {1, 1} -> 2
 ]
Out[94]=

Merge indicators are shown in the gap between two plots. Consequently, the indicators cannot be shown if Spacings is effectively set to 0:

In[95]:=
ResourceFunction["PlotGrid"][
 {
  {Plot[Sin[x], {x, -\[Pi], \[Pi]}, Frame -> True]},
  {Plot[Cos[x], {x, -\[Pi], \[Pi]}, Frame -> True]}
  },
 "MergeAxes" -> "Cut"
 ]
Out[95]=

Set Spacings to something non-zero to avoid this issue:

In[96]:=
ResourceFunction["PlotGrid"][
 {
  {Plot[Sin[x], {x, -\[Pi], \[Pi]}, Frame -> True]},
  {Plot[Cos[x], {x, -\[Pi], \[Pi]}, Frame -> True]}
  },
 "MergeAxes" -> "Cut",
 Spacings -> 25
 ]
Out[96]=

Neat Examples (2) 

Use PlotGrid to create new types of compound plots:

In[97]:=
data =
  RandomVariate[
   BinormalDistribution[{0, 0}, {1, 2}, 0.6], 1000
   ];
ResourceFunction["PlotGrid"][
 {
  {Histogram[data[[All, 2]], 20, Sequence[
    BarOrigin -> Left, Frame -> True, FrameTicks -> {{True, False}, {False, False}}, PlotRange -> {Automatic, {-7, 7}}, PlotRangePadding -> 0, GridLines -> {None, Automatic}]],
   ListPlot[data, Sequence[
    Axes -> False, Frame -> True, GridLines -> Automatic, PlotRangePadding -> 0, PlotRange -> {{-4, 4}, {-7, 7}}]]},
  {Graphics[{}, Frame -> True, FrameTicks -> None],
   Histogram[data[[All, 1]],
    20, Sequence[
    Frame -> True, FrameTicks -> {{False, False}, {True, False}}, PlotRange -> {{-4, 4}, Automatic}, PlotRangePadding -> 0, GridLines -> {Automatic, None}]]
   }
  },
 ItemSize -> {{1, 3}, {3, 1}},
 "MergeAxes" -> None
 ]
Out[98]=

Create the plot on the overview page of the PlotGridDoc paclet:

In[99]:=
SeedRandom[1];
data1 = Accumulate /@ RandomReal[{-1, 1}, {2, 100}];
data2 = {
   RandomVariate[NormalDistribution[0, 1], 500],
   RandomVariate[NormalDistribution[3, 1/2], 500]
   };
func3 = Table[BesselJ[n, x], {n, 5}];
ResourceFunction["PlotGrid"][
 {{
   ListLinePlot[
    data1,
    Sequence[
    Frame -> True, PlotTheme -> "VibrantColors", Filling -> Bottom, DataRange -> {0, 10}, BaseStyle -> {FontSize -> 15}, FrameStyle -> Black]
    ],
   Histogram[
    data2,
    Sequence[
    Frame -> True, PlotTheme -> "VibrantColors", BaseStyle -> {FontSize -> 15}, FrameStyle -> Black]
    ]
   },
  {
   Plot[
    Evaluate@func3,
    {x, 0, 10},
    Sequence[
    Frame -> True, PlotTheme -> "VibrantColors", BaseStyle -> {FontSize -> 15}, FrameStyle -> Black]
    ], SpanFromAbove}},
 Spacings -> {35, 10},
 "ShowFrameLabels" -> {{Automatic}, {Full}},
 PlotLabels -> Automatic -> Style["a)", Large, Black],
 ItemSize -> {{2, 1}, 1.59},
 ImageSize -> 590,
 Epilog -> {Black, Thick, Arrow@{{1, 1} -> {8.9, data1[[2, 89]]}, {2, 1} -> Block[{x = Pi}, {x, func3[[2]]}]}}
 ]
Out[100]=

Publisher

Lukas Lang

Compatibility

Wolfram Language Version 12.3

Version History

  • 1.0.1 – 29 September 2024
  • 1.0.0 – 29 September 2024

License Information

MIT License

Paclet Source

See Also