Group Abstract Group Abstract

Message Boards Message Boards

Sizing and Placing a Caption Under a Plot

GROUPS:

Hello everyone,

I've created a plot and a caption for it. The caption is a few lines long. I want to size the caption so that it is the same width of the plot and then place it under the plot. I would then export the two combined as a PDF. I created the caption using Column. I tried the following:

Labeled[myPlot, myCaption]

and

Column[{myPlot, myCaption}]

but no matter how much I mess around with ItemSize in the Column used to create the caption, I can't get it the right size, and I cannot get it centered under the plot. Also, if I change the size of the plot, the size of the caption will be wrong even if I did get it right. Any suggestions? I don't want to use Inset in Plot because the size of the caption will affect the overall size of the plot, and I have to maintain a strict plot size.

Gregory

POSTED BY: Gregory Lypny
Answer
4 months ago

Perhaps something like this? You may have to do a little tweaking of the parameters:

With[{imageSize = 500},
Pane[
Column[{
Plot[x, {x, 1, 3}, ImageSize -> imageSize]
Row[{TextCell[
"I've created a plot and a caption for it. The caption is a \n few lines long. I want to size the caption so that it is the same \n width of the plot and then place it under the plot. I would then \n export the two combined as a PDF.", "Text"]},
ImageSize -> imageSize + 30]
}
],
ImageSize -> imageSize + 50]
]

And you can change the "Text" in the TextCell CellStyle to whatever other CellStyle you might wish. Or you can add options to the TextCell to control aspects such as the FontSize as in:

With[{imageSize = 500}, 
Pane[Column[{Plot[x, {x, 1, 3},
ImageSize ->
imageSize] Row[{TextCell[
"I've created a plot and a caption for it. The caption is a \
few lines long. I want to size the caption so that it is the same \
width of the plot and then place it under the plot. I would then \
export the two combined as a PDF.", "Text", FontSize -> 10]},
ImageSize -> imageSize + 30]}], ImageSize -> imageSize + 50]]
POSTED BY: David Reiss
Answer
4 months ago

Thanks David,

I'll give it a try. Never thought of using TextCell. Wonder if it will work within a Manipulate, although that's really not a concern for me.

Thanks once again,

Gregory

POSTED BY: Gregory Lypny
Answer
4 months ago