Unitalicizing a label with a sub/superscript

I'm adding this answer because I think it is the simplest solution.

ListPlot[{1, 4, 5},
 Frame -> True,
 FrameLabel -> {Subsuperscript[x, g, 2], y}]

plot

Edit

Johu has a raised a valid issue in his comment. Here is a solution that addresses it.

ListPlot[{1, 4, 5},
 Frame -> True,
 FrameLabel -> {Subsuperscript[Style["x", "TI"], Style["g", "TR"], "2"], "y"}]

Mathematica graphics

If someone asks where the mystical "TI" and "TR" styles come from: They are heavily used in the reference pages. So if you see something like this in the documentation

img

you can use Ctrl+Shift+E to see the underlying box-expression and you will note that the same style-definitions are used.

Note

Quite a lot of information on named styles such "TR" can be found on this page


ListPlot[{1, 4, 5}, Frame -> True, ImageSize -> Tiny, 
  FrameLabel -> ({Subsuperscript[x, "g", 2], "y"})]~Magnify~3

enter image description here

I think it happens because StandardForm for output plots has TraditionalForm applied to it. TraditionalForm formats differently String-s and Symbol-s. Example:

Magnify[Subsuperscript["x", "g", 2] // TraditionalForm, 2]
Magnify[Subsuperscript[x, "g", 2] // TraditionalForm, 2]

enter image description here


In my opinion, it is better to avoid linear syntax strings (the kind of strings you get when you apply 2D typesetting structures inside of a string) and instead just use expressions. So, I like this:

Superscript[Subscript[x, g], 2]

instead of:

"\!\(\*SuperscriptBox[SubscriptBox[\(x\), \(g\)], \ \(2\)]\)"

Now, the reason that some characters get italicized is because by default ListPlot renders labels in TraditionalForm, and TraditionalForm uses the option SingleLetterItalics->True. So, to avoid having g italicized, you could override this with:

FrameLabel -> {Superscript[Subscript[x, Style[g, Plain]], 2], y}

or:

FrameLabel -> {Superscript[Subscript[x, "g"], 2], y}

where the latter works because "g" is not a single letter symbol.

Visualization:

ListPlot[
    {1, 4, 5},
    Frame -> True,
    FrameLabel -> {Superscript[Subscript[x, Style[g, Plain]], 2], y}
]

enter image description here