This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)

GraphicsGrid

GraphicsGrid
generates a graphic in which the are laid out in a two-dimensional grid.
  • If the are graphics with ImageSize->Automatic, GraphicsGrid will if possible resize them to make them fit into the grid as well as possible, while preserving their individual aspect ratios.
  • The output from GraphicsGrid can interactively be resized, or edited as a graphic.
  • The in GraphicsGrid do not all need to be the same length; there will be empty space in the grid at the ends of shorter rows.
  • The following specify that a particular position should be spanned:
SpanFromLeftspan from left
SpanFromAbovespan from above
SpanFromBothspan from both left and above
  • The following options can be given:
Alignment{Center,Center}horizontal and vertical alignment of elements
AspectRatioAutomaticratio of height to width for the whole grid
BackgroundNonewhat background colors to use
BaselinePositionAutomaticwhat to align with the surrounding text baseline
BaseStyle{}base style specifications for the grid
DividersNonewhere to draw divider lines in the grid
FrameNonewhere to draw frames in the grid
FrameStyleAutomaticstyles to use for frames
ImageSizeAutomaticoverall size of the whole graphics grid
ItemAspectRatioAutomaticratio of height to width for each item
SpacingsScaled[0.1]horizontal and vertical spacings
  • With AspectRatio->Automatic, the aspect ratio of the whole graphics grid will be chosen so as to best fit the individual objects in the grid.
  • Settings for the options Alignment, Background, and Framecan be given as follows to apply separately to different items:
specapply spec to all items
{specx}apply at successive horizontal positions
{specx,specy}apply at successive horizontal and vertical positions
{spec_(x),spec_(y),rules}also allow explicit rules for individual elements
  • The can have the following forms:
{s1,s2,...,sn}use through , then use defaults
{{c}}use in all cases
{{c1,c2}}alternate between and
{{c1,c2,...}}cycle through all
{s,{c}}use , then repeatedly use
{s1,{c},sn}use , then repeatedly use , but use at the end
{s1,s2,...,{c1,c2,...},sm,...,sn} use the first sequence of at the beginning, then cyclically use the , then use the last sequence of at the end
{s1,s2,...,{},sm,...,sn}use the first sequence of at the beginning and the last sequence at the end
{i1->v1,i2->v2,...}specify what to use at positions
{spec,rules}use rules to override specifications in spec
  • With settings of the form , if there are more specified than items across the grid, from the beginning are used for the first items, and ones from the end are used for the last items.
  • Common settings for Frame include:
Noneno frame
Trueframe around the whole grid
Allframe around every item in the grid
{All,False}put a frame at every horizontal position (column lines)
{False,All}put a frame at every vertical position (row lines)
specapply spec to all gaps between items
{specx,specy}apply to successive horizontal and vertical gaps
  • For a grid with items in a particular direction, Dividers and Spacings can specify settings for the gaps between elements, starting before the first element and ending after the last element.
Axisaxis of the middle row in the grid (default)
Baselinebaseline of the middle row in the grid
Bottombottom of the whole grid
Centerhalfway from top to bottom
Toptop of the whole grid
{{i,j},pos}position pos in element
  • The settings for BaseStyle are appended to the default style typically given by the style in the current stylesheet.
Display elements in a graphics grid:
Put a frame around every element:
Display elements in a graphics grid:
In[1]:=
Click for copyable input
Out[1]=
 
Put a frame around every element:
In[1]:=
Click for copyable input
Out[1]=
Put a frame around the whole grid:
Put a frame around every element:
Draw all the frames in red:
Put a frame around the first row and column:
Draw different frames with different styles:
Put dividers at all horizontal positions:
Put dividers at all vertical positions:
Put dividers at the third horizontal and second vertical positions:
Make element 4 span the column to its right:
Make it span two columns:
Make element 2 span the row below it:
Make it span two rows:
Span throughout a 2×2 block:
Align contents to the left:
Align contents to the right:
Draw the grid with a pink background:
A pink background for the column at the first horizontal position:
Alternating pink and yellow at successive vertical positions:
Alternating pink and yellow at successive horizontal positions:
Embed styling options with a particular grid item:
Set the spacing between items:
Set the horizontal and vertical spacings separately:
The overall aspect ratio is automatically adjusted for irregular shapes:
Grids can be nested:
If possible GraphicsGrid will choose an aspect ratio suitable to its elements:
When no reasonable choice can be made, a default aspect ratio of 1 is used:
Setting the aspect ratio of each item explicitly:
Draw the grid with a pink background:
Pink and red backgrounds for the first and second horizontal positions:
An equivalent syntax:
Pink and red backgrounds for the first and second vertical positions:
Alternating pink and red backgrounds:
Alternating backgrounds with yellow superimposed in the first and last positions:
Blending of colors:
Set the background for specific items:
Set the background for a subregion of the grid:
Align the center of the grid with the baseline of surrounding text:
Align the bottom of the grid with the baseline:
Frame the entire grid:
Frame all elements in the grid:
Frame specific elements:
Frame a region:
FrameStyle supports a variety of graphics directives:
FrameStyle is applied to all sources of grid lines, including Dividers and Item:
Directives given with FrameStyle are combined with those specified elsewhere:
By default, GraphicsGrid will display graphics at their specified sizes:
Giving an ImageSize setting to the GraphicsGrid will scale the graphics appropriately:
Make a picture of the first 64 elementary cellular automata:
Show a collection of discrete mappings:
To span across both rows and columns requires appropriate use of SpanFromBoth:
New in 6