4
$\begingroup$

I am plotting the following data data = {{{0, 32.5}}, {{2, 23.7}, {5,22.35}, {10,20.13}}, {{2, 29.75}, {5, 25.4}, {10,25.5}}, {{5, 29.9}, {10, 28.75}}, {{5,30.75}, {10,26.65}}}; with the instruction

ListPlot[data,PlotRange -> {{0, 10}, {15, 35}},PlotRangePadding -> {1, 0}, PlotMarkers ->Thread[{ChartElementData["SimpleMarkers"][[All, 1]] /.Thickness[_] :> AbsoluteThickness[4], .07}],PlotStyle -> ColorData[40, "ColorList"], PlotLegends -> Placed[LineLegend[{"s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8"},LabelStyle -> {Black, FontFamily -> "Helvetica", FontSize -> 20},LegendMarkerSize -> 20], Right],FrameLabel -> {"parameter", "property"}, FrameTicks -> {Automatic, Automatic, None, None},GridLines -> {Automatic,Automatic},ImageSize -> 600]

as you can see in the image below:

enter image description here

I get some unwanted frames around the triangle up and down symbols in the legend (for s4 and s5). How to get rid of them? Also, I would like to shift the legend upwards. How to do it?

I am using Mathematica 10.0.2 thanks

$\endgroup$

1 Answer 1

4
$\begingroup$
data = RandomInteger[40, {5, 10}];
lp = ListPlot[data, PlotRange -> {{0, 10}, {15, 35}}, 
  PlotRangePadding -> {1, 0}, 
  PlotMarkers -> Thread[{ChartElementData["SimpleMarkers"][[All, 1]] /. 
      Thickness[_] :> AbsoluteThickness[4], .07}], 
  PlotStyle -> ColorData[40, "ColorList"], 
  PlotLegends -> Placed[LineLegend[{"s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8"},
      LabelStyle -> {Black, FontFamily -> "Helvetica", 
       FontSize -> 20}, LegendMarkerSize -> 20], Right], 
  FrameLabel -> {"parameter", "property"}, 
  FrameTicks -> {Automatic, Automatic, None, None}, 
  GridLines -> {Automatic, Automatic}, ImageSize -> 600]

enter image description here

You can post-process to remove the unwanted rectangle around the markers:

lp /. {Opacity[_], Rectangle[__]}:> {}

enter image description here

$\endgroup$
2
  • $\begingroup$ Ho to shift the legend upwards or downwards? $\endgroup$
    – Luigi
    Jul 13, 2018 at 8:12
  • $\begingroup$ @Luigi, you can replace Right with {After, Top} or with {After, Bottom} in the last argument of Placed. To get a finer control of placement you can replace Right with ImageScaled[{1, .3}] and play with the numbers to get the position you like. $\endgroup$
    – kglr
    Jul 13, 2018 at 9:07

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.