Dynamically labeling a family of curves [duplicate]

This question already has an answer here:

Labeling individual curves in Mathematica

8 answers

I have created some simple code which generates a plot. This plot contains a family of curves created by changing a single parameter “k”. I use the Table function within the Show function to iterate through the desired values of “k” which in turn creates the family of curves. The code and resultant plot is shown below:

ur[x_, a_] := 1 – (1/a)*Log[1 + a x]
g[x_, go_, s_, m_] := 1/2 (go*x*Exp[-(x/s)])/(1 + m x)

uh[x_, a_, go_, s_, m_, k_] := ur[x, a] + g[x, go, s, m]/(1 – g[x, go, s, m]) (k – 1)

(* initialize parameters *)
a = 5; go = 1; s = 2; m = 0.5;

plt[k_] := ParametricPlot[{ uh[x, a, go, s, m, k], x}, {x, 0, 1},
PlotRange -> {0.6, 1.4}, {0, 1.5}}, AspectRatio -> 1/1.5,
Frame -> True, PlotStyle -> {Darker[Green]},
FrameLabel -> {Style[“Normalized Volume”, 16],
Style[“Normalized Pressure”, 16]},
LabelStyle -> {FontSize -> 14, FontFamily -> “Times”}]

Show[Table[plt[k], {k, 1.0, 3.5, 0.5}]]

The question is, “How do you create a plot with labeling generated by the Table function?” This question seems similar to another question recently asked, but I was not able to fold that solution into my code framework. The desired plot might look something like the following image…

Thank you in advance for any suggestions and/or comments.



1 Answer


You could add in a label function:

label[k_, x_] := Graphics@Text[“k = ” <> ToString[k], {uh[x, a, go, s, m, k], x}, {0, -1}];

Then show it all together:

Show[Table[{plt[k], label[k, 1]}, {k, 1.0, 3.5, 0.5}]]



Thank you for your help! This is what I needed. A function to programmatically place a label. Very Nice! I guess the question I asked was similar to other questions I just could not see a solution from the answers. I’m still learning.
– Joseph
May 8 ’13 at 16:00