Preface
This is a tutorial made solely for the purpose of education and it was designed for students taking Applied Math 0330. It is primarily for students who have very little experience or have never used Mathematica before and would like to learn more of the basics for this computer algebra system. As a friendly reminder, don't forget to clear variables in use and/or the kernel.
Finally, the commands in this tutorial are all written in bold black font, while Mathematica output is in normal font. This means that you can copy and paste all commands into Mathematica, change the parameters and run them. You, as the user, are free to use the scripts for your needs to learn the Mathematica program, and have the right to distribute this tutorial and refer to this tutorial as long as this tutorial is accredited appropriately.
Return to computing page for the second course APMA0340
Return to Mathematica tutorial for the second course APMA0330
Return to Mathematica tutorial for the first course APMA0340
Return to the main page for the course APMA0340
Return to the main page for the course APMA0330
Return to Part I of the course APMA0330
Labeling Figures
Label lines:
To see the equation of the line when cursor reaches the graph, use Tooltip command:
Plot[Tooltip[Sin[x]], {x, 0, 8 Pi}]
To put text/title on the picture, use Epilog command:
Plot[Sin[x], {x, 0, 8 Pi}, Epilog -> Text["My Text", Offset[{32, 0}, {14, Sin[14]}]]]

To write labels on the graph:
fns[x_] := {1 + x^3, 2 + 8*x};
len := Length[fns[x]];
Plot[Evaluate[fns[x]], {x, 0, 6}, Epilog ->
Table[Inset[
Framed[DisplayForm[fns[x][[i]]], RoundingRadius -> 5], {5,
fns[5][[i]]}, Background -> White], {i, len}]]

You can do something similar with Locators that allows you to move the labels wherever you want:
fns[x_] := {Log[x], Exp[2*x], Sin[4*x], Cos[6*x]};
DynamicModule[{pos = Table[{1, fns[1][[i]]}, {i, len}]},
LocatorPane[Dynamic[pos], Plot[Evaluate[fns[x]], {x, 0, 1.8}],
Appearance ->
Table[Framed[Text@TraditionalForm[fns[x][[i]]],
RoundingRadius -> 5, Background -> White], {i, len}]]]
Export["label2.png",%]

Plotting with axes, without axes
There are times when the axes could interfere with displaying certain functions and solutions to ODEs. Fortunately, getting rid of axes in recent versions of Mathematica is very easy.
One method of specifying axes is to use the above options, but there is also a visual method of changing axes. Let us plot the function \( f(x) = 2\,\sin 3x -2\,\cos x \) without ordinate but using green color and font size 12 for abscissa:
Plot[f[x], {x, 0, 2*Pi}, PlotStyle -> {Thick, Blue}, Axes -> {True, False}, AxesStyle -> Directive[Green, 12]]


We can plot two graphs in the same figure:
![]() |
![]() |
AxesStyle -> {Directive[Green, 12], Red}, PlotLabel -> 2*Sin[3*x] - 2*Cos[x]] Plot[f[x], {x, 0, 2*Pi}, PlotStyle -> {Thick, Blue}, Axes -> {True},
AxesStyle -> {Directive[Green, 12], Red},
PlotLabel -> Style[Framed[2*Sin[3*x] - 2*Cos[x]], 16, Black, Background -> Lighter[Yellow]]]
![]() |
![]() |
We show how to present data using GraphicsGrid command:
