# Positioning labels in 3D plots ... again

I am looking for a way to manually control the positioning of labels in a 3D plot. For this purpose I used to follow the methods of the accepted answers in:

Axes Origin & Labels in 3D Plot

Manually assigning Axes label position in Plot3D

which basically achieves that using Show and something like

Graphics3D[Text["x", Scaled[{0.5, -0.2, -0.2}] ]

I'm guessing this has something to do with the version 13.1, but this no longer works. In this version I can't even reproduce the accepted solutions above anymore. The labels simply don't show up.

Example:

Show[{Plot3D[x^2 + y^2 + 3, {x, -3, 3}, {y, -3, 3},PlotRange -> {-1, 20}],Graphics3D[{Text["x", Scaled[{-.05, .5, 0}], {0, -1}], Text["y", Scaled[{.5, -.05, 0}], {0, -1}], Text["z", Scaled[{.5, .5, 1.1}]]}]}]

returns:

no x y z labels...

I think the problem is that Scaled brings the label outside the boundingbox of Graphics3D, but PlotRange doesn't fix that. I can play with Scaled to bring the labels into the plot. In this picture it still may look fine to bring the labels inside, but in other cases it doesn't.

Also, if possibe, I'd like the answer not to involve the function Text, because for aesthetic reasons I use the package Matex, to produce labels as in

Graphics3D[Inset[MaTeX["x"], Scaled[{0.5, -0.2, -0.2}] ] ]

and hence some functionalities of Text may not carry over. Alternatives to this approach are also welcome though. Thank you.

Here is a more precise way to do that where you can arbitrary control the positions of labels and even rotate

lebl = MaTeX["\\color{red}\\text{Lable}", FontSize -> 14];
axeslebl = MaTeX[#, FontSize -> 14] & /@ {"X", "Y", "Z"};

then you get (Note that LM Roman 12 is the same font as MaTeX)

Plot3D[x^2 + y^2 + 3, {x, -3, 3}, {y, -3, 3}, PlotRange -> {-1, 20},
LabelStyle -> {FontFamily -> "LM Roman 12", Black, FontSize -> 14},
Epilog -> {Text[lebl, Scaled[{.5, 1.1}]],
Rotate[Text[axeslebl[[1]], Scaled[{.25, 0.02}]], -\[Pi]/10],
Rotate[Text[axeslebl[[2]], Scaled[{.94, 0.2}]], \[Pi]/3],
Rotate[Text[axeslebl[[3]], Scaled[{-0.1, 0.5}]], \[Pi]/1.8]},
ImagePadding -> 40, AspectRatio -> 1]

• For Graphics3D,Inset work.
ResourceFunction["MaTeXInstall"][];
<< MaTeX
Graphics3D[{{Opacity[.2], Cuboid[]},
Inset[MaTeX["x", Magnification -> 4], {0.5, -0.2, -0.2}],
Inset[MaTeX["O", Magnification -> 4], {0.5, 0.5, 0.5}]},
Boxed -> False]

• Plot3D, we can also use AxesLabel and Labeled.
<< MaTeX

Plot3D[Labeled[x^2 + y^2 + 3,
MaTeX["\\mathcal{A}", Magnification -> 2], {.5, .5},
Background -> None], {x, -3, 3}, {y, -3, 3}, PlotRange -> {-1, 20},
AxesLabel -> {MaTeX["x", Magnification -> 3],
MaTeX["y", Magnification -> 3], MaTeX["z", Magnification -> 3]}]

• What font isMaTeX using? Very pretty! Aug 24, 2022 at 0:13
• @NicholasG Here is the default font of LaTeX ,we can set another fonts as show in szhorvat.net/pelican/latex-typesetting-in-mathematica.html Aug 24, 2022 at 0:15
• Many thanks. I do not see the font Latin Modern in my PC installation of 13.1. There is a Modern No. 20, which seems somewhat close. Aug 24, 2022 at 0:21
• Graphics3D[{{Opacity[.2], Cuboid[]}, Inset[MaTeX["x", Magnification -> 4], {0.5, -.2, 0}, Automatic, Automatic, AngleVector[-π/10]], Inset[MaTeX["y", Magnification -> 4], {1.2, .5, 0}, Automatic, Automatic, AngleVector[-π/6]], Inset[MaTeX["z", Magnification -> 4], {1.2, 1, .5}], Inset[MaTeX["O", Magnification -> 4], {0.5, 0.5, 0.5}]}, Boxed -> False] Aug 24, 2022 at 14:30
• I am not sure I understand your answer. If LaTeX uses the font Latin Modern, as it seems to do, then the font Latin Modern must be a publicly available font, and I should be able to install it and use it directly from Mathematica without having to install MaTeX. No? Aug 25, 2022 at 11:23