5
$\begingroup$

I have a set of figures that I would like to show as grid for a publication. I currently just export the figure as an eps and use another software package to add Labels (A,B,C,D) to each panel of the figure. This is rather tedious to do. Is there a way to label each panel in Mathematica? For example is it possible to label each panel of the following grid?

a = Plot[Sin[x], {x, -Pi, Pi}];

b = Plot[Cos[x], {x, -Pi, Pi}];

c = Plot[ArcSin[x], {x, -Pi, Pi}];

d = Plot[ArcCos[x], {x, -Pi, Pi}];

Grid[{{a, b}, {c, d}}, Spacings -> {1, 2}, Frame -> All]
$\endgroup$
4
$\begingroup$

Or if you want a Grid solution:

a = Plot[Sin[x], {x, -Pi, Pi}];
b = Plot[Cos[x], {x, -Pi, Pi}];
c = Plot[ArcSin[x], {x, -Pi, Pi}];
d = Plot[ArcCos[x], {x, -Pi, Pi}];

col[text_, plot_] := Column[{text, plot}, Alignment -> Center]
labels = Text[Style[#, 18]] & /@ {"Sin", "Cos", "ArcSin", "ArcCos"};
Grid[Partition[col @@@ Thread[{labels, {a, b, c, d}}], 2], 
  Spacings -> {1, 2}, Frame -> All]

Mathematica graphics

$\endgroup$
  • $\begingroup$ No need to make col a function; it already is one. :-) You could also use MapThread[col, {labels, {a, b, c, d}}] or make col Listable and then use col[labels, {a, b, c, d}] directly. $\endgroup$ – Mr.Wizard Aug 4 '17 at 14:03
6
$\begingroup$

You can use PlotLabels for each individual graph:

labelstyle={Bold,18};
a = Plot[Sin[x], {x, -Pi, Pi},PlotLabel->Style[Sin,labelstyle]];
b = Plot[Cos[x], {x, -Pi, Pi},PlotLabel->Style[Cos,labelstyle]];
c = Plot[ArcSin[x], {x, -Pi, Pi},PlotLabel->Style[ArcSin,labelstyle]];
d = Plot[ArcCos[x], {x, -Pi, Pi},PlotLabel->Style[ArcCos,labelstyle]];
Grid[{{a, b}, {c, d}}, Spacings -> {1, 2}, Frame -> All]

enter image description here

$\endgroup$
6
$\begingroup$

Is this what you want

a = Plot[Sin[x], {x, -Pi, Pi}, AspectRatio -> 1, 
    Epilog -> Inset[Style["(a)", 18], 
    Offset[{-1, -1}, Scaled[{1, 1}]], {Right, Top}]];
b = Plot[Cos[x], {x, -Pi, Pi}, AspectRatio -> 1, 
    Epilog -> Inset[Style["(b)", 18], 
    Offset[{-1, -1}, Scaled[{1, 1}]], {Right, Top}]];
c = Plot[ArcSin[x], {x, -Pi, Pi}, AspectRatio -> 1, 
    Epilog -> Inset[Style["(c)", 18], 
    Offset[{-1, -1}, Scaled[{1, 1}]], {Right, Top}]];
d = Plot[ArcCos[x], {x, -Pi, Pi}, AspectRatio -> 1, 
    Epilog -> Inset[Style["(d)", 18], 
    Offset[{-1, -1}, Scaled[{1, 1}]], {Right, Top}]];
GraphicsGrid[{{a, b}, {c, d}}, AspectRatio -> 1, Spacings -> {1, 2}, 
Frame -> All]

enter image description here

$\endgroup$
  • $\begingroup$ Yes that is what I am looking for. Actually what I used is a combination from your and @Oska's response. I have a title for each of my plots in the figure, so I could just replace the title used in Oska's response with A-D slide that label to the left or right of the panel. All of the response solve my question so thanks everyone! $\endgroup$ – tarhawk Jun 10 '14 at 16:06
5
$\begingroup$

Labeled:

plots = Plot[#[x], {x, -Pi, Pi}] & /@ {Sin, Cos, ArcSin, ArcCos};
labels = Style[#, "Section", 18, Black] & /@ {"Sin", "Cos", "ArcSin", "ArcCos"};
labeledplots = Labeled[#1, #2, Top] & @@@ Transpose[{plots, labels}];

Grid[Partition[labeledplots, 2], Spacings -> {2, 2}, Dividers -> All]

Mathematica graphics

Panel:

paneledplots = Panel[#, #2, {{Top, Center}}, Appearance -> "Frameless"] & @@@ 
   Transpose[{plots, labels}];

Grid[Partition[paneledplots, 2], Dividers -> All, Spacings -> {2, 2}, 
   ItemSize -> {15, Automatic}]

enter image description here

$\endgroup$
4
$\begingroup$

Changing the 4 last parameters of Partition the output becomes quite flexible:

 Grid[Partition[Plot[#@x, {x, -Pi, Pi}, PlotLabel -> Style[#, 12, Bold]] & /@
         {Sin, Cos, ArcSin, ArcCos, Tan}, 2, 2, 1, {}], Spacings -> {1, 2}, Frame -> All]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.