Labeling Axes and Plots

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, additional formatting functions for superscripts and subscripts are presented in this section.

Labels for axes are specified by the option AxesLabel -> {..., ..., ...}, 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 -> 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, Axes -> True, AxesLabel -> axeslabel]
WriteLiveForm["meshPlaneText5.lg3d", example]

Resulting applet:

In this example, we have also set Boxed -> 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 rotate with 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, 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, 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.


Next Page: Animations

Table of Contents

  1. Introduction
  2. LiveGraphics3D Overview
  3. LiveGraphics3D Input
  4. Parametrized Graphics
  5. Moving Lines and Polygons
  6. Including Text
  7. Labeling Axes and Plots
  8. Animations
  9. Occlusions of Objects
  10. Intersecting Objects
  11. Two-Dimensional Mathlets
  12. Stereo Images
  13. Generating Graphical Input
  14. Advanced Examples
  15. Future Directions
  16. References