Observe the inconsistency in the appearance of the title on the following plots:
label = "\!\(\*SqrtBox[\(Test\)]\)"
Plot[{t, t^2}, {t, 0, 1}, PlotLabel -> label]
Plot[{t, t^2}, {t, 0, 1}, PlotLabel -> label,
PlotLegends -> ""]
Plot[{t, t^2}, {t, 0, 1}, PlotLabel -> label,
PlotLegends -> Placed[Automatic,
{Right, Center}]]
The output of "label" and the title of the second Plot
entry appear as
but the titles of the first and third Plot
entries appear as
What's going on here, and how can I consistently produce the first (smaller) appearance in plot titles regardless of the PlotLegend
setting? The trick of using the dummy setting PlotLegends->""
will not work because I am trying to place a legend inside my plot image, as in the third entry.
Incidentally, this issue only seems to arise when capital letters are used inside the square root sign. If "Test" is replaced with "test", for example, the issue vanishes. But alas, I need to place a combination of lowercase and uppercase letters under the square root sign in my application.
EDIT:
There was an answer (now deleted, for some reason) suggesting
Plot[{t, t^2}, {t, 0, 1}, PlotLegends ->
{Placed[label,
{Top, Center}], Placed[Automatic,
{Right, Center}]}]
This works except that now "Test" is formatted with a different style from typical PlotLabel
. It is formatted with the same style as the output of label
, which is different from that of PlotLabel
, as pointed out by Michael E2 in the comments.
To see the difference observe the output of
Plot[{t, t^2}, {t, 0, 1}, PlotLabel -> label,
PlotLegends ->
{Placed[label,
{Top, Center}], ""}]
Incidentally, I have found another solution that seems to work:
Labeled[Plot[{t, t^2}, {t, 0, 1},
PlotLabel -> label], ""]
Still, seems hacky and it would be nice to understand what's going on with the different display styles.
EDIT 2:
The workaround I proposed just above actually isn't ideal because when I save as PDF, the blank label creates extra space under the plot image. Also, as an added wrinkle, even when using this trick, right-clicking the image and then choosing "Save Graphic As..." and saving as a PDF reverts the label to the "bad" form with too much space inside the square root sign! After selecting the whole cell, right-clicking and choosing "Save Selection As..." and saving as a PDF, the square root prints properly but the blank space is added at the bottom. What a mess!
label
is typeset with a different style than inPlot
. My plots all have the same look (V12.2, Mac). -- The output ofStyle[label, "Graphics", Larger]
seems to match my plots. $\endgroup$MaTeX
package for nicer-looking and perfectly uniform labels... $\endgroup$