0

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?

Sulli
  • 2,185
  • 14
  • 28
  • What version are you using? – Öskå Jul 29 '14 at 16:14
  • @Ö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 – Sulli Jul 29 '14 at 16:20
  • What I was about to tell you is that Needs["PlotLegends`"] is obsolete, the Plot option PlotLegends should be used now. – Öskå Jul 29 '14 at 16:22
  • @Ö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? – Sulli Jul 29 '14 at 16:27
  • 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 :) – Öskå Jul 29 '14 at 16:40
  • Anyway, you can use Disk[{0, 0}, Scaled@.2] (or any number you want) instead of a radius of 1. See here. – Öskå Jul 29 '14 at 16:42
  • @Öskå in fact my problem is that I use Show to plot multiple graphics. Following this question http://mathematica.stackexchange.com/questions/3518/using-plotlegends-with-show-messes-up-the-graphics , it seems like the best solution is to use ShowLegend in this situation and PlotLegends won't work with Show? – Sulli Jul 29 '14 at 17:25
  • Have you tried that? – Öskå Jul 29 '14 at 17:28
  • @Öskå it works really well! – Sulli Jul 29 '14 at 18:38

1 Answers1

1

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

seismatica
  • 5,101
  • 1
  • 22
  • 33