Skip to main content
added 5 characters in body
Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929

I have the following plot showing six curves. The curves "DotDashed Blue and Red" correspond to p=ap=a, "Solid Orange and Magenta" correspond to p=bp=b, and, "Dashed Purple and Gray" correspond to p=cp=c. I want to label these cases in a single Legend as shown

 p1 = Plot[{Exp[-x] Sin[5 x], -Exp[-x] Sin[5 x]}, {x, 0, 2 \[Pi]}, 
   PlotRange -> All, 
   PlotStyle -> {{Red, DotDashed}, {Blue, DotDashed}}];
p2 = Plot[{2 Exp[-x] Sin[5 x], -2 Exp[-x] Sin[5 x]}, {x, 0, 2 \[Pi]}, 
   PlotRange -> All, PlotStyle -> {Magenta, Orange}];
p3 = Plot[{4 Exp[-x] Sin[5 x], -4 Exp[-x] Sin[5 x]}, {x, 0, 2 \[Pi]}, 
   PlotRange -> All, PlotStyle -> {{Purple, Dashed}, {Gray, Dashed}}];

join = Show[p3, p2, p1];

Needs["PlotLegends`"]
ShowLegend[
 Show[join, 
  ImageSize -> 
   300], {{{Graphics[{{Red, Blue}, DotDashed, Thickness[0.115], 
      Line[{{0, 0}, {2, 0}}]}], 
    Style["p=a", FontFamily -> "Arial", Italic, 
     FontSize -> 8]}, {Graphics[{{Purple, Orange}, Thickness[0.115], 
      Line[{{0, 0}, {2, 0}}]}], 
    Style["p=b", FontFamily -> "Arial", Italic, 
     FontSize -> 8]}, {Graphics[{{Magenta, Gray}, Dashed, 
      Thickness[0.115], Line[{{0, 0}, {2, 0}}]}], 
    Style["p=c", FontFamily -> "Arial", Italic, FontSize -> 8]}}, 
  LegendLabel -> "" , LegendPosition -> {0.461, 0.340}, 
  LegendSize -> {0.45, 0.3}, LegendShadow -> False}]

I have the following plot showing six curves. The curves "DotDashed Blue and Red" correspond to p=a, "Solid Orange and Magenta" correspond to p=b, and, "Dashed Purple and Gray" correspond to p=c. I want to label these cases in a single Legend as shown

 p1 = Plot[{Exp[-x] Sin[5 x], -Exp[-x] Sin[5 x]}, {x, 0, 2 \[Pi]}, 
   PlotRange -> All, 
   PlotStyle -> {{Red, DotDashed}, {Blue, DotDashed}}];
p2 = Plot[{2 Exp[-x] Sin[5 x], -2 Exp[-x] Sin[5 x]}, {x, 0, 2 \[Pi]}, 
   PlotRange -> All, PlotStyle -> {Magenta, Orange}];
p3 = Plot[{4 Exp[-x] Sin[5 x], -4 Exp[-x] Sin[5 x]}, {x, 0, 2 \[Pi]}, 
   PlotRange -> All, PlotStyle -> {{Purple, Dashed}, {Gray, Dashed}}];

join = Show[p3, p2, p1];

Needs["PlotLegends`"]
ShowLegend[
 Show[join, 
  ImageSize -> 
   300], {{{Graphics[{{Red, Blue}, DotDashed, Thickness[0.115], 
      Line[{{0, 0}, {2, 0}}]}], 
    Style["p=a", FontFamily -> "Arial", Italic, 
     FontSize -> 8]}, {Graphics[{{Purple, Orange}, Thickness[0.115], 
      Line[{{0, 0}, {2, 0}}]}], 
    Style["p=b", FontFamily -> "Arial", Italic, 
     FontSize -> 8]}, {Graphics[{{Magenta, Gray}, Dashed, 
      Thickness[0.115], Line[{{0, 0}, {2, 0}}]}], 
    Style["p=c", FontFamily -> "Arial", Italic, FontSize -> 8]}}, 
  LegendLabel -> "" , LegendPosition -> {0.461, 0.340}, 
  LegendSize -> {0.45, 0.3}, LegendShadow -> False}]

I have the following plot showing six curves. The curves "DotDashed Blue and Red" correspond to p=a, "Solid Orange and Magenta" correspond to p=b, and, "Dashed Purple and Gray" correspond to p=c. I want to label these cases in a single Legend as shown

p1 = Plot[{Exp[-x] Sin[5 x], -Exp[-x] Sin[5 x]}, {x, 0, 2 \[Pi]}, 
   PlotRange -> All, 
   PlotStyle -> {{Red, DotDashed}, {Blue, DotDashed}}];
p2 = Plot[{2 Exp[-x] Sin[5 x], -2 Exp[-x] Sin[5 x]}, {x, 0, 2 \[Pi]}, 
   PlotRange -> All, PlotStyle -> {Magenta, Orange}];
p3 = Plot[{4 Exp[-x] Sin[5 x], -4 Exp[-x] Sin[5 x]}, {x, 0, 2 \[Pi]}, 
   PlotRange -> All, PlotStyle -> {{Purple, Dashed}, {Gray, Dashed}}];

join = Show[p3, p2, p1];

Needs["PlotLegends`"]
ShowLegend[
 Show[join, 
  ImageSize -> 
   300], {{{Graphics[{{Red, Blue}, DotDashed, Thickness[0.115], 
      Line[{{0, 0}, {2, 0}}]}], 
    Style["p=a", FontFamily -> "Arial", Italic, 
     FontSize -> 8]}, {Graphics[{{Purple, Orange}, Thickness[0.115], 
      Line[{{0, 0}, {2, 0}}]}], 
    Style["p=b", FontFamily -> "Arial", Italic, 
     FontSize -> 8]}, {Graphics[{{Magenta, Gray}, Dashed, 
      Thickness[0.115], Line[{{0, 0}, {2, 0}}]}], 
    Style["p=c", FontFamily -> "Arial", Italic, FontSize -> 8]}}, 
  LegendLabel -> "" , LegendPosition -> {0.461, 0.340}, 
  LegendSize -> {0.45, 0.3}, LegendShadow -> False}]
Source Link
H. Kenan
  • 663
  • 6
  • 13

PlotLegends for six curves

I have the following plot showing six curves. The curves "DotDashed Blue and Red" correspond to p=a, "Solid Orange and Magenta" correspond to p=b, and, "Dashed Purple and Gray" correspond to p=c. I want to label these cases in a single Legend as shown

 p1 = Plot[{Exp[-x] Sin[5 x], -Exp[-x] Sin[5 x]}, {x, 0, 2 \[Pi]}, 
   PlotRange -> All, 
   PlotStyle -> {{Red, DotDashed}, {Blue, DotDashed}}];
p2 = Plot[{2 Exp[-x] Sin[5 x], -2 Exp[-x] Sin[5 x]}, {x, 0, 2 \[Pi]}, 
   PlotRange -> All, PlotStyle -> {Magenta, Orange}];
p3 = Plot[{4 Exp[-x] Sin[5 x], -4 Exp[-x] Sin[5 x]}, {x, 0, 2 \[Pi]}, 
   PlotRange -> All, PlotStyle -> {{Purple, Dashed}, {Gray, Dashed}}];

join = Show[p3, p2, p1];

Needs["PlotLegends`"]
ShowLegend[
 Show[join, 
  ImageSize -> 
   300], {{{Graphics[{{Red, Blue}, DotDashed, Thickness[0.115], 
      Line[{{0, 0}, {2, 0}}]}], 
    Style["p=a", FontFamily -> "Arial", Italic, 
     FontSize -> 8]}, {Graphics[{{Purple, Orange}, Thickness[0.115], 
      Line[{{0, 0}, {2, 0}}]}], 
    Style["p=b", FontFamily -> "Arial", Italic, 
     FontSize -> 8]}, {Graphics[{{Magenta, Gray}, Dashed, 
      Thickness[0.115], Line[{{0, 0}, {2, 0}}]}], 
    Style["p=c", FontFamily -> "Arial", Italic, FontSize -> 8]}}, 
  LegendLabel -> "" , LegendPosition -> {0.461, 0.340}, 
  LegendSize -> {0.45, 0.3}, LegendShadow -> False}]