Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I use ListPlot in order to plot four sets of data and also insert legends in my plot. Here is the Mathematica code

data1 = {{0, 48}, {50, 59}, {100, 69}, {150, 78}, {200, 86}, {250, 
87}, {300, 88}, {350, 88.5}, {400, 89}, {450, 89.5}, {500, 90}};
data2 = {{0, 50}, {21, 57}, {45, 65}, {69, 73}, {100, 82}, {150, 
86}, {200, 90}, {250, 90.5}, {300, 91}, {350, 92}, {400, 
93}, {450, 93.5}, {500, 94}};
data3 = {{0, 55}, {50, 60}, {100, 65}, {150, 72}, {200, 80}, {250, 
84}, {300, 87}, {350, 89}, {400, 91}, {450, 91.5}, {500, 92}};
data4 = {{0, 63}, {50, 66}, {100, 69}, {150, 72}, {200, 74.5}, {250, 
77}, {300, 79}, {350, 81}, {400, 83}, {450, 85}, {500, 87}};

col = {Blue, Darker[Green], Red, Magenta};
leg = {"\!\(\*SubscriptBox[\(L\), \(z\)]\) = 5", 
"\!\(\*SubscriptBox[\(L\), \(z\)]\) = 20", 
"\!\(\*SubscriptBox[\(L\), \(z\)]\) = 40", 
"\!\(\*SubscriptBox[\(L\), \(z\)]\) = 60"};
plrange = {45, 100};

P0 = ListPlot[{data1, data2, data3, data4}, Frame -> True, 
PlotStyle -> Table[{Thickness[0.003], col[[i]]}, {i, 1, 4}], 
Joined -> True, PlotMarkers -> {Automatic, 12}, 
FrameLabel -> {Subscript["M", "n"], 
"Percentage of chaotic orbits (%)"}, 
FrameStyle -> Directive[FontSize -> 17, FontFamily -> "Helvetica"], 
PlotRange -> plrange, Axes -> False, ImageSize -> 600, 
PlotLegends -> 
LineLegend[leg, LegendMarkers -> Automatic, 
LegendMarkerSize -> {{20, 25}}, 
LabelStyle -> 
 Directive[FontSize -> 15, FontFamily -> "Helvetica"]]]

which produces the following output using version 9

enter image description here

My main issue is how to increase the size of the plot markers in the legend. Inside the main plot, I can control the size of the markers by PlotMarkers -> {Automatic, 12}. On the other hand, even though I tried a lot, I cannot do the same regarding the markers in the legend. Any ideas?

Many thanks in advance.

share|improve this question
    
You can try defining your own LegendMarkers. –  b.gatessucks May 6 '13 at 6:46
    
You mean of course inside the PlotLegends. How could I do this? Any clue? –  Vaggelis_Z May 6 '13 at 6:56
add comment

1 Answer 1

up vote 9 down vote accepted

You also aren't getting the right line thickness in your legend. I'd suggest a slightly different route, of creating custom legend markers, similar to the method described in this answer, and including them in a SwatchLegend.

legmarkers =  MapThread[Graphics[{#1, AbsoluteThickness[2], 
     Line[{{-1, 0}, {1, 0}}], #2}] &, {col, {Disk[{0, 0}, 0.3], 
    Rectangle[{-0.3, -0.3}, {0.3, 0.3}], 
    GeometricTransformation[
     Polygon[{{-0.3, -0.3}, {0.3, -0.3}, {0.3, 0.3}, {-0.3, 0.3}}], 
     RotationTransform[45 Degree]], 
    Polygon[0.3 ({{1, -Sqrt[3.]/2}, {0, 
         Sqrt[3]/2}, {-1, -Sqrt[3.]/2}})]} }]

enter image description here

You can then specify the markers as shown. Notice that I had to tweak the LegendMarkerSize option to get the aspect ratio of the graphics correct.

P0 = ListPlot[{data1, data2, data3, data4}, Frame -> True, 
  PlotStyle -> Table[{Thickness[0.003], col[[i]]}, {i, 1, 4}], 
  Joined -> True, PlotMarkers -> {Automatic, 12}, 
  FrameLabel -> {Subscript["M", "n"], 
    "Percentage of chaotic orbits (%)"}, 
  FrameStyle -> Directive[FontSize -> 17, FontFamily -> "Helvetica"], 
  PlotRange -> plrange, Axes -> False, ImageSize -> 600, 
  PlotLegends -> 
   SwatchLegend[leg, LegendMarkers -> legmarkers , 
    LegendMarkerSize -> {{30, 12}}, 
    LabelStyle -> 
     Directive[FontSize -> 15, FontFamily -> "Helvetica"]]]

enter image description here

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.