# Constructing Mathlets Quickly using LiveGraphics3D - Labeling Axes and Plots

Author(s):
Jonathan Rogness and Martin Kraus

Apart from Text primitives, which may be positioned arbitrarily, LiveGraphics3D also allows you to place labels at predefined positions for each axis and the whole plot. Apart from the discussion of these labels, this section also describes additional formatting functions for superscripts and subscripts.

Labels for axes are specified by the option AxesLabel -&gt; {..., ..., ...}, which is set to a list of three labels, one for each axis. These labels are specified in exactly the same way as the first argument of the Text primitive, including the possibility of using formatting functions such as StyleForm or StringForm. In addition to specifying the labels with AxesLabel, you also have to specify Axes -&gt; True to display them. Here is an example:

(* all but the last three commands are the same as in the previous example *)

axeslabel = {StyleForm["x", FontFamily -> "Times", FontSize -> 20],
StyleForm["y", FontFamily -> "Times", FontSize -> 20],
StyleForm["z", FontFamily -> "Times", FontSize -> 20]};

example = Graphics3D[
{mesh, point, xSection, ySection, tanplane},
Boxed -> True, Lighting -> False, Axes -> True, AxesLabel -> axeslabel]
WriteLiveForm["meshPlaneText5.lg3d", example]


Resulting applet:

In this example, we have also set Boxed -&gt; True to display all edges of the bounding box.

To label the whole plot, you can use the option PlotLabel. The specified label is centered below the top edge of the mathlet. This is particular useful if you do not want a label to move when you rotate the scene. The required commands to include a plot label displaying the value of the dependent variable z are:

(* all but the last three commands are the same as in the previous example *)

plotlabel = StyleForm[
StringForm["Plot of 2*y*Exp[-x^2-y^2]; Current z value = 1", z],
FontFamily -> "Times", FontSize -> 20];

example = Graphics3D[
{mesh, point, xSection, ySection, tanplane},
Boxed -> False, Lighting -> False, PlotLabel -> plotlabel]
WriteLiveForm["meshPlaneText6.lg3d", example]


Resulting applet:

As you rotate the plot, the plot label will keep its position. Note also that the function value included in the label is updated as you drag the red point.

However, there is no need to use this syntax for mathematical expressions in labels. We can produce a more traditional mathematical notation with the help of formatting functions such as Superscript, Subscript, Subsuperscript, Overscript, Underscript, Underoverscript, OverBar, OverDot, OverHat, OverTilde, OverVector, and UnderBar. Here is an example with Superscript that also uses italics for names of variables:

(* all but the last three commands are the same as in the previous example *)
plotlabel=StyleForm[StringForm["Plot of  2 1 2; Current 3 value = 4",
StyleForm["y", FontSlant -> "Italic"],
Superscript["e", StringForm["-1-2",
Superscript[StyleForm["x", FontSlant->"Italic"], "2"],
Superscript[StyleForm["y", FontSlant->"Italic"], "2"]]],
StyleForm["z", FontSlant -> "Italic"],                 zDisplay],
FontFamily->"Times", FontSize->20];  example = Graphics3D[
{mesh, point, xSection, ySection, tanplane},
Boxed -> False, Lighting -> False, PlotLabel -> plotlabel]
WriteLiveForm["meshPlaneText7.lg3d", example]


Note the reference to zDisplay; this is defined as a dependent variable within the <applet>tag by the rule zDisplay -> Round[1000 * z] / 1000. This trick, which reduces the number of displayed digits, was introduced in the previous section.

Resulting applet:

There is still much more to say about text labels in LiveGraphics3D; however, by now you should have got a fairly good idea of how to do basic text formatting with the help of LiveGraphics3D.

Jonathan Rogness and Martin Kraus, "Constructing Mathlets Quickly using LiveGraphics3D - Labeling Axes and Plots," Convergence (May 2006)

## JOMA

Journal of Online Mathematics and its Applications