0
$\begingroup$

I have a Grid object and want to put a label near its corner or edge. The label will overlap with the boundary, not fully inside the Grid region. The following example doesn't work well since the label is partly concealed. Note that I need to work with Grid rather than GraphicsGrid.

plot = Grid[
   Table[Plot[Sin[i x + j \[Pi]/3], {x, -\[Pi], \[Pi]}], {i, 2}, {j, 2}]];
Labeled[plot, "Label", {{Bottom, Right}}, Spacings -> {Automatic, -0.5}]
Labeled[plot, "Label", {{Bottom, Center}}, Spacings -> {Automatic, -0.5}]

enter image description here

$\endgroup$

1 Answer 1

1
$\begingroup$

Use Legended and Placed instead of Labeled:

plot = Grid[
   Table[Plot[Sin[i x + j \[Pi]/3], {x, -\[Pi], \[Pi]}], {i, 2}, {j, 2}]];
Legended[plot, {Placed["Label", {1, 0.05}]}]

Legended

$\endgroup$
3
  • $\begingroup$ I actually had tried this, but it can't put the label across the boundary. Not what I need. Sorry if the original title misled you. $\endgroup$
    – xiaohuamao
    Jul 10, 2021 at 14:14
  • $\begingroup$ What about this inelegant workaround with Spacings: plot = Grid[Table[Plot[Sin[i x + j \[Pi]/3], {x, -\[Pi], \[Pi]}], {i, 2}, {j, 2}], Spacings -> {{0, 0}, {0, 0, 0.5}}, Frame -> True, FrameStyle -> Transparent]; Legended[plot, {Placed["Label", {1, 0}]}] $\endgroup$
    – Domen
    Jul 10, 2021 at 14:48
  • $\begingroup$ Thanks. It somewhat works. I'm surprised that turning on Frame can have such an effect. Let's see if any other answers. $\endgroup$
    – xiaohuamao
    Jul 11, 2021 at 5:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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