0
$\begingroup$

I am making a plot using

 f[m_, i_] := i + Sqrt[m];

  LazyDriftPlot = Plot[
  Evaluate@Append[Table[f[m, i], {i, 0, 40, 10}], f[m, 5.5]], {m, 1, 
   100},
  PlotLabel -> "Average lazy drift",
  PlotLegends -> Append[Table[i, {i, 0, 40, 10}], 5.5],
  AxesLabel -> {
    Style[m, FontSize -> 18], Style[d[m], FontSize -> 18]
    }
  ]

How can I add a label to the legend here?

I've tried

PlotLegends -> {Append[...],LegendLabel->"MyLabel"}

but it is ignored.

$\endgroup$
1
$\begingroup$

SwatchLegend comes to the rescue!

LazyDriftPlot = 
 Plot[Evaluate@Append[Table[f[m, i], {i, 0, 40, 10}], f[m, 5.5]], {m, 
   1, 100}, PlotLabel -> "Average lazy drift", 
  PlotLegends -> 
   SwatchLegend[Append[Table[i, {i, 0, 40, 10}], 5.5], 
    LegendMarkers -> "Line", LegendLabel -> "MyLabel"], 
  AxesLabel -> {Style[m, FontSize -> 18], 
    Style[d[m], FontSize -> 18]}]

Hope this helps !

$\endgroup$
  • $\begingroup$ Thank you, SwatchLegend! $\endgroup$ – Three Diag Oct 5 '17 at 9:34

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.