1
$\begingroup$

I am running this code:

Plot3D[#, {x, -5, 5}, {y, -5, 5}, PlotRange -> {-5, 10}] & /@ {x, y, 
   Abs[x], Abs[y], Abs[x + y], Abs[x] + Abs[y]} // 
 GraphicsGrid[{#, {"x", "y", 
     "\[LeftBracketingBar]x\[RightBracketingBar]", 
     "\[LeftBracketingBar]y\[RightBracketingBar]", 
     "\[LeftBracketingBar]x+y\[RightBracketingBar]", 
     "\[LeftBracketingBar]x\[RightBracketingBar]+\[LeftBracketingBar]\
y\[RightBracketingBar]"}}] &

to produce this result:

list of plots

which is great. But I would like the labels to be rendered closer to the plots. Is there some way to do that with GraphicsGrid?

(I don't really want to be using a GraphicsGrid – I actually want to be using a GraphicsRow, with labels below the plots. But I can't figure out how to do that. This is the best hack I have come up with.)

$\endgroup$
  • 1
    $\begingroup$ Replace GraphicsGrid by Grid? $\endgroup$ – OkkesDulgerci Mar 29 '18 at 3:37
  • 1
    $\begingroup$ Try Labeled[Plot3D[#, {x, -5, 5}, {y, -5, 5}, PlotRange -> {-5, 10}], TraditionalForm[#]] & /@ {x, y, Abs[x], Abs[y], Abs[x + y], Abs[x] + Abs[y]}. $\endgroup$ – J. M.'s technical difficulties Mar 29 '18 at 3:37
  • $\begingroup$ I would accept either of these as a solution. What's the protocol? Should I convert both into a solution & accept? Or should I just delete the question as trivial? $\endgroup$ – billc Mar 29 '18 at 3:41
  • $\begingroup$ use GraphicsRow[ Labeled @@@ Transpose[{#, TraditionalForm /@ {x, y, Abs[x], Abs[y], Abs[x + y], Abs[x] + Abs[y]}}]] & instead of GraphicsGrid[...]&? $\endgroup$ – kglr Mar 29 '18 at 3:43
2
$\begingroup$

You can use PlotLabel if you don't mind having the labels above the plots:

GraphicsRow[
    Map[
        Plot3D[#,{x,-5,5},{y,-5,5},PlotRange->{-5,10},PlotLabel->#]&,
        {x,y,Abs[x],Abs[y],Abs[x+y],Abs[x]+Abs[y]}
    ],
    ImageSize->800
]

enter image description here

For labels below the plot you can use Labeled (as in the comments) or PlotLegends:

GraphicsRow[
    Map[
        Plot3D[#,{x,-5,5},{y,-5,5},PlotRange->{-5,10},PlotLegends->Placed[#,Below]]&,
        {x,y,Abs[x],Abs[y],Abs[x+y],Abs[x]+Abs[y]}
    ],
    ImageSize->800
]

enter image description here

| improve this answer | |
$\endgroup$
  • $\begingroup$ thanks Carl. I've never seen the Placed directive before, it looks good to know about. $\endgroup$ – billc Mar 29 '18 at 4:23

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.