Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I'm a newbie at Mathematica and I couldn't find how to label the maximum and the zero of a simple function in Plot with their names:

rho[r_] = 1 - r^2;
Plot[rho[r], {r, -1, 1}, AxesLabel -> {r, \[Rho]}] 

and i want to show the maximum on the plot with

Subscript[\[Rho], c]

and the point rho[1] with

Subscript[R, TF]
share|improve this question
    
Look up Text[] or Inset[]. –  J. M. Apr 3 '13 at 16:15

3 Answers 3

up vote 2 down vote accepted

How about:

 rho[r_] = 1 - r^2;
 pl = Plot[rho[r], {r, -1, 1}, AxesLabel -> {r, \[Rho]}];

then

Show[{pl, Graphics[Text[Subscript[\[Rho], c], {0.05, 1.05}]],
Graphics[Text[Subscript[R, TF], {1.05, 0.05}]]}, PlotRange -> All]

Mathematica graphics

share|improve this answer
    
Thanks for this clear answer! –  Sibylle Apr 3 '13 at 18:36

You can put Text and Point on a plot with Epilog.

Plot[rho[r - Pi], {r, 1, 5},
 AxesLabel -> {r, \[Rho]},
 Epilog -> {
   PointSize[.01], Red, Point[zero],
   Black, Point[max], Map[Text[#[[1]], #[[2]], {0, -2}] &,
    Transpose[{{-Subscript["R", "TF"],
       Subscript["R", "TF"], Subscript["\[Rho]", "c"]},
      Join[zero, {max}]}]]},
 PlotRange -> All,
 PlotRangePadding -> .5]

plot

Calculated maximum and zeroes:

max = {r /. Last@#, First@#} &[FindMaximum[rho[r - Pi], r]]
{3.14159, 1.}

zero = {r, 0} /. NSolve[rho[r - Pi] == 0, r]
{{2.14159, 0}, {4.14159, 0}}
share|improve this answer

Using my answer to this question, you can generate any of the following interactively:

Mathematica graphics

The only change needed is to remove the "String" in

InputField[Dynamic[lbl1[[#]]],String]

and

InputField[Dynamic[lbl2[[#]]],String]

to be able to type expressions.

The interactive interface looks like this:

Mathematica graphics

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.