# Plotting with sub and superscripts on the PlotLabels

Bug persists through 12.0.

I'm trying to produce a plot with PlotLabels that include sub- and superscripts. However, I haven't been able to do it consistently. Currently I'm trying to do this with the basic math assistant palette and the code is thus:

Plot[30, {x, 0, 605}, PlotStyle -> {Dashed, Thick, Black},
PlotLabels -> "\!$$\*SubsuperscriptBox[\(x$$, $$s$$, $$*$$]\)"]


But there is rather strange gap between the plot and the label which you can see from the picture below. Is there a way to move the label closer to the plot?

Running the same code without the sub and superscripts produces no issue.

Looks like a bug in PlotLabels to me - my guess is that when measuring the size of the label, it does not take into account how big the rendered string will be, only the raw (rather long) string. A work-around is to wrap the label in Row@{...}:

Plot[30, {x, 0, 605},
PlotStyle -> {Dashed, Thick, Black},
PlotLabels -> Row@{
"\!$$\*SubsuperscriptBox[\(x$$, $$s$$, $$*$$]\)"
}
]


Other potential wrappers include StandardForm[...] and TraditionalForm[...] (which will render the label a bit differently) - essentially anything that hides the raw string from PlotLabels seems to do the trick.

• Ah that explains why removing either the sub or the superscript only made the gap slightly shorter. I tried couple of workarounds with InputForm etc. without a positive results. However, Row seems to do it. Thank you. – Harto Saarinen Oct 15 '19 at 11:21
• @HartoSaarinen Please consider writing a bug report on the issue to support(at)wolfram.com. – Alexey Popkov Oct 15 '19 at 11:59
• Pane also works as well for a workaround – chuy Oct 15 '19 at 16:02