I like labeling my images with the variables used, so that when exported, I do not lose crucial information about the graph involved.

Up until now, something along the lines of

Epilog -> {Text["w = " <> ToString[w], Scaled[{.3, .8}]]}

has been sufficient, but this only works well for decimal numbers and integers. Fractions turn out like this:

w = 10

how can I either make the output appear as

$w = 10/\pi$


$w = \frac{10}{\pi}$

Plot[Sin@x, {x, 0, 2 Pi}, Epilog -> {Text["w = " <> ToString@StandardForm[10/Pi], 
     Scaled[{.3, .8}]]}]

Mathematica graphics


This is one possibility:

  Plot[Sin[x], {x, 0, 2 \[Pi]}, 
 Epilog -> {Inset[
    Style["w=\!\(\*FractionBox[\(10\), \(\[Pi]\)]\)", 12], 
    Scaled[{0.552, 0.825}]], 
   Inset[Graphics[{Red, Arrowheads[0.05], 
      Arrow[{Scaled[{0.552, 0.825}], Scaled[{0.455, 0.7}]}], Red, 
      PointSize[0.03], Point[Scaled[{0.441, 0.68`}]]}]]}]

This is another:

  Plot[Sin[x], {x, 0, 2 \[Pi]}],

  (* This is the text *)
   Text[Style["w=\!\(\*FractionBox[\(10\), \(\[Pi]\)]\)", 12], 
    Scaled[{0.552, 0.825}]]],

  (* These are the point and the arrow  *)
  Graphics[{Red, Arrowheads[0.03], 
    Arrow[{Scaled[{0.51, 0.794}], Scaled[{0.455, 0.7}]}], Red, 
    PointSize[0.015], Point[Scaled[{0.437, 0.676}]]}]


The both yield the following:

enter image description here

Note that parameters in these two cases (such as the points coordinates or sizes) are slightly different.

There are few more possibilities. One can use the TraditionalForm or the Box language, for instance and one can choose either of them. I prefer the second approach, which has advantages, if I make a complex image containing lots of details in addition to the initial plot. The advantage is then only technical, but quite important. It consists in the possibility to place each new detail of the image into a separate Graphics statement, such statements being separated from one another visually (and, occasionally, by comments as I did above). This helps me to easily return to the image and redraw it, if needed.

Have fun!


Since V6, the simplest way to produce formatted output almost anywhere is with Row, often with the aid of Style. In this case, I think only Row is needed.

With[{w = 1/π}, 
  Plot[x, {x, 0, 1}, Epilog -> {Text[Row[{"w = ", w}], Scaled[{.3, .8}]]}]]


  • $\begingroup$ I like this one as well, since it saves code lines when there's more parameters to insert! $\endgroup$ Aug 16 '15 at 18:29

If you are striving for consistency and are happy with Mathematica's formatting,

Plot[Sin@x, {x, 0, 2 Pi}, 
 Epilog -> {Text[Unevaluated[w = 10/Pi], Scaled[{.3, .8}]]}]

works well, too, without the need for explicit conversion to strings or string concatenation.

  • $\begingroup$ An alternative to Unevaluated is HoldForm. $\endgroup$
    – Michael E2
    Aug 13 '15 at 16:53

This site is temporarily in read only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .