2
$\begingroup$

Here is a simple example:

a = Plot[x^2, {x, 0, 10}]

aa = Labeled[Plot[x^2, {x, 0, 10}], "a", Top]

GraphicsRow[{a, aa}]

Which gives the following image as an output: example of graphics grid not scale correctly?

The labeled plot is smaller than the unlabeled plot (and there is excess white space, but the white space can maybe be fixed by manually setting padding or something?)

How can I avoid this from happening?, (and maybe why does this happen?)


A couple things I wish to note:

  • I would prefer to stick with a solution that labels an existing plot and combines them, as opposed to adding labels to the plotting functions, if at all possible.
  • I believe a similar issue happens if the GraphicsRow is formed from two labeled plots (they will be the same size, but "zoomed out".
  • Maybe this is just a zoom/aspect ratio problem? Sorry if it is so easy and I just don't know how to do it.

Also, there are similar questions, so perhaps my question is a duplicate? For example, this and this. But those seem more about asking how to label a grid, whereas I want to know how to make this method here give the same size output, and also why this issue occurs. (Also, I don't quite understand the answers in those questions)

$\endgroup$

1 Answer 1

2
$\begingroup$

Use a label consisting of a spacer.

Clear["Global`*"]

a = Labeled[Plot[x^2, {x, 0, 10}], " ", Top];
aa = Labeled[Plot[x^2, {x, 0, 10}], "a", Top];
GraphicsRow[{a, aa}]

enter image description here

Alternatively,

a = Plot[x^2, {x, 0, 10}, PlotLabel -> " "];
aa = Plot[x^2, {x, 0, 10}, PlotLabel -> "a"];
GraphicsRow[{a, aa}]

enter image description here

$\endgroup$
1
  • $\begingroup$ Thank you for your solution. I think the first code is the same as just labeling both plots (one of the labels being blank). This indeed makes them the same size, but if you compare the first solution to the second, the plots are "smaller" (more white space?). Is there a way to fix this? If not, I think all the built-in plot commands take PlotLabel as an option, so I can probably add it as an option to my functions, so I can turn it on/off at will. $\endgroup$
    – user106860
    Mar 24, 2021 at 23:04

Your Answer

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

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