Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I often seek to display two graphs, side by side, with a common label over them. There is no option for adding a label to GraphicsRow, which means, I think, that I need to use Grid or GraphicsGrid and include a row on top that has SpanFromLeft set to allow a graphically defined line of text occupy the entire row.

It seems like a lot of work to do something simple. Is there a better solution?

share|improve this question
5  
You can use Labeled –  rm -rf Sep 24 '13 at 0:07

4 Answers 4

up vote 17 down vote accepted

GraphicsRow takes a PlotLabel option:

p1 = Plot[Sin[x], {x, 0, Pi}, PlotLabel -> Sin];
p2 = Plot[Cos[x], {x, 0, Pi}, PlotLabel -> Cos];
GraphicsRow[{p1, p2}, PlotLabel -> "Two plots"]

enter image description here

share|improve this answer
    
I can't imagine how I missed this. Thanks. –  Michael Stern Sep 24 '13 at 0:36
5  
@MichaelStern Easy to miss since it's not in the GraphicsRow documentation :) –  ssch Sep 24 '13 at 0:38
    
@Michael Indeed, this is the first time I can recall seeing this, so thank you for asking the question! (+1 of course, ssch) –  Mr.Wizard Sep 24 '13 at 0:50

Possibly more versatile, but you have to mess with text overlapping your plots, but GraphicsRow also accepts Epilog

GraphicsRow[{Plot[Sin[x], {x, 0, 4 Pi}], Plot[Cos[x], {x, 0, 4 Pi}]}, 
 Spacings -> Scaled[0.4], 
 Epilog -> Inset["Plot Title", Scaled[{0.5, 0.95}]]]

Mathematica graphics

share|improve this answer
3  
PlotRangePadding -> {0, {0, 25}} could help avoid possible text/plot collisions. –  ssch Sep 24 '13 at 0:24
    
@ssch Thanks - I figured there was a padding option, but couldn't put my finger on it. –  bobthechemist Sep 24 '13 at 0:26
1  
I'd accept this answer too, if only StackExchange would let me. –  Michael Stern Sep 24 '13 at 0:36

When I need more interface control, I usually do something like this:

p1=Plot[Sin[x],{x,0,Pi},PlotLabel->Sin,ImageSize->150];
p2=Plot[Cos[x],{x,0,Pi},PlotLabel->Cos,ImageSize->150];
title=Panel[Style["Test Label",White,20],ImageSize->300,Background->Orange,Alignment->Center];
Deploy@Grid[{{title,SpanFromLeft},{p1,p2}},Dividers->Gray,Spacings->{0,0}]

enter image description here

share|improve this answer

Few additional methods:

p1 = Plot[Sin[x], {x, 0, 2 Pi}, ImageSize -> 200];
p2 = Plot[Cos[x], {x, 0, 2 Pi}, ImageSize -> 200];

Labeled

Labeled[Panel@GraphicsRow[{p1, p2}], Style["Label", "Subsubsection"], Top] // Panel

enter image description here

Panel

Panel[GraphicsRow[{p1, p2}], Style["Label", "Subsubsection"], Top] // Panel
(* same picture *)

Legended

Legended[Panel@GraphicsRow[{p1, p2}], Placed[Style["Label", "Subsubsection"], Top]] // Panel
(* same picture *)

Show with PlotLabel

Show[GraphicsRow[{p1, p2}],  PlotLabel -> Style["Label", "Subsubsection"]] // Panel

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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