0

Possible Duplicate:
How do I label different curves in Mathematica?

Using Mathematica, I would like to programmatically add text labels to each member of a family of curves. I'd prefer not to use a legend. Here's an example:

f[x_, a_] := a*x
myplot = Plot[Evaluate@Table[f[x, a], {a, {0.5, 1, 2}}], {x, -5, 5}]
mytext = Graphics[Evaluate@Table[Text["a = " <> ToString[a], 
                                      {5, f[5, a]}, {1, 0}], {a, {0.5, 1, 2}}]]
Show[myplot, mytext]

enter image description here

There has to be a better or more standard way of doing this...right? My hack isn't terribly pretty. The text bleeds into the plot for a = 1 and a = 0.5

I went through the interactive way of adding text labels as outlined by Add Text to a Graphic. I'd really like to do this programmatically though.

What do people do in practice? Do people prefer to interactively add labels because of the potential headache of doing it programmatically?

Community
  • 1
  • 1
lowndrul
  • 3,423
  • 6
  • 33
  • 52
  • This being closed as exact duplicate, could someone involved maybe provide links to one or two of those? It is not obvious (to me, at least) how to find the prior incantations. – Daniel Lichtblau Sep 23 '11 at 20:52
  • 2
    @Daniel The link appears at the top of the closed question (somewhat confusingly labelled "possible duplicate") and also under the "Linked" section in the right-hand sidebar. – WReach Sep 23 '11 at 21:21
  • 2
    @WReach Thanks for making obvious the, well, obvious (which apparently I can still miss). – Daniel Lichtblau Sep 23 '11 at 21:39

0 Answers0