1
$\begingroup$

I'm trying to use ListLinePlot for 3 data sets, and I want to put borders for my legends. Here is my code:

series1 = {{3.8,0.}, {3.8,1.587}, {4.9,1.587}, {4.9,3.175}, {5.3,3.175}, {5.3,61.905}, {5.4,61.905}, {5.4,68.254}, {5.5,68.254}, {5.5,92.063}, {5.6,92.063}, {5.6,100.}, {9.1,100.}};
series2 = {{3.8,0.}, {5.7,0.}, {5.7,15.873}, {5.8,15.873}, {5.8,28.571}, {5.9,28.571}, {5.9,34.921}, {6.,34.921}, {6.,49.206}, {6.1,49.206}, {6.1,57.143}, {6.2,57.143}, {6.2,63.492}, {6.3,63.492}, {6.3,68.254}, {6.4,68.254}, {6.4,74.603}, {6.5,74.603}, {6.5,77.778}, {6.6,77.778}, {6.6,84.127}, {6.8,84.127}, {6.8,85.714}, {7.3,85.714}, {7.3,87.302}, {7.4,87.302}, {7.4,88.889}, {7.7,88.889}, {7.7,92.063}, {7.8,92.063}, {7.8,93.651}, {8.,93.651}, {8.,95.238}, {8.1,95.238}, {8.1,96.825}, {9.,96.825}, {9.,98.413}, {9.1,98.413}, {9.1,100.}};
series3 = {{6.5,0.}, {6.5,100}};

ListLinePlot[{series1, series2, series3},
   PlotStyle -> {{Thickness[Large],GrayLevel[0]}, 
       {Dashing[{Small, Small}],GrayLevel[0]}, {Dotted,Red}},
   Frame -> True, Joined -> True, GridLines -> Automatic,
   FrameLabel -> {"x", "y"}, PlotLegends -> {"series1", "series2"},
   LegendBorder -> Black,
   LabelStyle -> Directive[Bold, FontFamily -> "Times", FontSize -> 14, Frame -> True]
]

Unfortunately, the LegendBorder does not work and Mathematica gives me this error:

ListLinePlot::optx: Unknown option LegendBorder-> in ListLinePlot[<<1>>].

Is there anyway to resolve this issue? Thanks.

$\endgroup$
7
$\begingroup$

LegendBorder doesn't exist. Use LineLegend

 ListLinePlot[{series1, series2, series3},
     PlotStyle -> {{Thickness[Large], 
        GrayLevel[0]}, {Dashing[{Small, Small}], GrayLevel[0]}, {Dotted, Red}},
     Frame -> True,
     GridLines -> Automatic,
     FrameLabel -> {"x", "y"},
     PlotLegends -> 
      LineLegend[{Black, {Gray, Dashed}}, {"series1", "series2"},
       LegendFunction -> (Framed[#, RoundingRadius -> 5] &),
       LegendMargins -> 5],
     LabelStyle -> 
      Directive[Bold, FontFamily -> "Times", FontSize -> 14,Frame -> True]]

enter image description here

$\endgroup$
  • $\begingroup$ Thank you very much! That was really helpful. Is there any way to reduce the border thickness of legends? $\endgroup$ – Alex Nov 14 '15 at 0:43
  • $\begingroup$ The only way I found to make a thin frame is with RoundingRadius->0 $\endgroup$ – eldo Nov 14 '15 at 11:01

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.