I want to label the local maxima, local minima, and points of inflection on a plot of a curve. How is this done in Mathematica?

  • 3
    $\begingroup$ Have you tried anything? Do you have an example function? $\endgroup$ – J. M.'s ennui Oct 10 '18 at 4:12

One way to produce such labeling as you ask for is to use Callout. However, Callout only works in plots and not in graphic directives. This complicates things a little because Epilog can't be used to show the points. I resort to plotting the curve on one plot and the critical points and their labels on another and then combining the two with Show.

Here is an example using a cubic polynomial as the curve.

f[x_] := x (x - 1) (x + 1)

pts = {#, f[#]} & /@ {-(1/Sqrt[3]), 0, 1/Sqrt[3]} // N;
lbls = {"max", "inflection", "min"};
places = {Automatic, Automatic, {.63, -.43}};

pts are the critical points
lbls are their labels
places are where they will be placed. Note that I only override Mathematica's automatic placement for the minimum. I was OK with the placement of the other two points. BTW, the point {.63, -.43} will be the position of the kink in the leader line of the minimum's callout.

With[{max = 1},
  curve = Plot[f[x], {x, -max, max}];
  points = 
    ListPlot[MapThread[Callout[#1, #2, #3] &, {pts, lbls, places}],
      PlotRange -> {{-max, max}, Automatic},
      PlotStyle -> {Red, AbsolutePointSize[8]}]];

Show[curve, points, PlotRange -> All]


  • $\begingroup$ I upvoted for going beyond what the OP provided. $\endgroup$ – J. M.'s ennui Oct 10 '18 at 7:06
  • 2
    $\begingroup$ @J.M.issomewhatokay. I had to because the OP essentially provided nothing. :-) $\endgroup$ – m_goldberg Oct 10 '18 at 14:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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