0
$\begingroup$

I have this graph:

ShowLegend[
Plot[Sin[x], {x, 0, 10}, Filling -> Axis, FillingStyle -> {Red, Blue}], 
{{{Graphics[{Blue, Disk[{0, 0}, 1]}, ImageSize -> 5], Sin[x] > 0}, {Graphics[{Red, Disk[{0, 0}, 1]}], Sin[x] < 0}}}]

enter image description here

and I would like to change the size of the disks in the legend. Unfortunately, using the ImageSize option doesn't work Graphics[{Red, Disk[{0, 0}, 1]},ImageSize -> 2]

What should I do in this case?

$\endgroup$
9
  • $\begingroup$ What version are you using? $\endgroup$ – Öskå Jul 29 '14 at 16:14
  • $\begingroup$ @Öskå version 9, although I might migrate to version 10 very soon, especially if you tell me it's easier to do so in version 10 $\endgroup$ – Sulli Jul 29 '14 at 16:20
  • $\begingroup$ What I was about to tell you is that Needs["PlotLegends`"] is obsolete, the Plot option PlotLegends should be used now. $\endgroup$ – Öskå Jul 29 '14 at 16:22
  • $\begingroup$ @Öskå Mathematica 9 told me it was obsolete, but it still seems to work, and I've seen many people on Stackexchange who don't recommend using PlotLegends? Was it before and now it works well? $\endgroup$ – Sulli Jul 29 '14 at 16:27
  • $\begingroup$ You may have seen many people who don't recommend using PlotLegend but PlotLegends instead :) Since v9 PlotLegend has been replaced by PlotLegends and it works pretty fine I think :) $\endgroup$ – Öskå Jul 29 '14 at 16:40
1
$\begingroup$

Just change the value of LegendMarkerSize to the size that you want. Look more into PlotLegends and SwatchLegend in the documentation.

Plot[Sin[x], {x, 0, 10}, Filling -> Axis, FillingStyle -> {Red, Blue},
  PlotLegends -> 
  SwatchLegend[{Blue, Red}, {"Sin(x) > 0", "Sin(x) < 0"}, 
   LegendMarkers -> Graphics[Disk[]], LegendMarkerSize -> 20, 
   LegendFunction -> Framed]]

Mathematica graphics

$\endgroup$

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