1

I have a question on plot labeling in Mathematica. I have

y = 4 x / L + 2

where

L = {10, 20, 30, 40}

I want to draw a graph of y vs. x. When I evaluate

Plot[y, {x, 0, 100}, 
   ImageSize -> Scaled[1.0],
   PlotLabel ->  Style["y vs X ", FontSize -> 18]]

I get four different lines in the same plot. I want to know how to label each line with its relevant L value; e.g., "l = 10" for the corresponding line.

Could anyone please tell me how to do this?

TMH
  • 419
  • 5
  • 12

1 Answers1

8

I think this is a duplicate but I couldn't find the original - so here it is along those lines:

y[x_, L_] := 4 x/L + 2

dat = {10, 20, 30, 40};

Plot[y[x, #] & /@ dat // Evaluate, {x, 0, 100}, 
 Epilog -> (Text["L = " <> ToString[#], {70, 0 + y[80, #]}] & /@ dat)]

enter image description here

Vitaliy Kaurov
  • 73,078
  • 9
  • 204
  • 355