4
$\begingroup$

I am making a simple plot with a legend:

ListPlot[{{1, 1}, {2, 2}}, PlotStyle ->Red, 
  PlotLegends -> Placed[PointLegend[{Style["data 1", FontSize -> 20]},
  LegendFunction -> (Framed[#, Background -> White, 
     FrameStyle -> Directive[Black, Thick]] &)],
  Scaled[{0.9, 0.15}]]
]

How to change the size of the symbol in the legend? I am using Mathematica 10.0.2.

$\endgroup$
1
  • 1
    $\begingroup$ Look up LegendMarkerSize. $\endgroup$
    – Szabolcs
    Sep 14, 2018 at 8:49

1 Answer 1

3
$\begingroup$

You can use the option setting LegendMarkers -> {Automatic, 20}:

ListPlot[{{1, 1}, {2, 2}}, PlotStyle -> Red, 
 PlotLegends -> Placed[PointLegend[{Style["data 1", FontSize -> 20]}, 
    LegendMarkers -> {Automatic, 20}, 
    LegendFunction -> (Framed[#, Background -> White, 
        FrameStyle -> Directive[Black, Thick]] &)], 
   Scaled[{0.85, 0.15}]]]

enter image description here

Alternatively, you can specify the PointSize in the first argument of PointLegend, e.g., using

PointLegend[{Directive[Red, PointSize[Large]]}, {Style["data 1", FontSize -> 20]}, 
 LegendFunction -> (Framed[#, Background -> White, 
     FrameStyle -> Directive[Black, Thick]] &)]

in the code above gives

enter image description here

$\endgroup$
5
  • $\begingroup$ If I do SetOptions[PlotLegends, LegendMarkers -> {Automatic, 20}] then I get an error LegendMarkers is not a known option for PlotLegends. >>. So, how to handle LegendMarkers in Options? $\endgroup$
    – Luigi
    Sep 17, 2018 at 7:47
  • $\begingroup$ @Luigi, PlotLegends does not have any options. You can try SetOptions[PointLegend, LegendMarkers -> {Automatic, 20}] . This should work (but it doesn't in version 9). $\endgroup$
    – kglr
    Sep 17, 2018 at 8:04
  • $\begingroup$ it does not work, also in version 10.0.2 $\endgroup$
    – Luigi
    Sep 17, 2018 at 8:20
  • $\begingroup$ do we see workarounds? $\endgroup$
    – Luigi
    Sep 17, 2018 at 8:40
  • $\begingroup$ @Luigi, a workaround is to use SetOptions[PointLegend, LegendMarkers -> {Automatic, 40}] and PlotLegends -:>PointLegend[...., Options[PointLegend]] $\endgroup$
    – kglr
    Sep 17, 2018 at 9:10

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.