2
$\begingroup$

I am trying to find the equivalent LegendMarkerSize value to the size specified for special characters when using LegendMarkers. So far I found LegendMarkerSize 14 generates symbols close to 22 set for those characters. Please compare code below, one using Graphics for LegendMarkers, the other using special charaters:

SwatchLegend[{Red, Blue, Orange},{"2007", "2011", "2012"}, LegendMarkers-> {Graphics[Disk[{0, 0}]],Graphics[Polygon[{{1, 0}, {0, 1}, {-1, 0}, {0, -1}}]],Graphics[Rectangle[]]}, LegendMarkerSize -> 14]

and

PointLegend[{Red, Blue, Orange}, {"2007", "2011", "2012"},LegendMarkers -> {{"\[FilledCircle]", 22}, {"\[FilledDiamond]", 22}, {"\[FilledSquare]", 22}}]

Also as a side note, the symbol generated by LegendMarkers using Graphics seem to have a surrounding edge while the one using special character looks cleaner.

$\endgroup$
3
  • $\begingroup$ Using LegendMarkers -> {{"\[FilledCircle]", 20}, {"\[FilledDiamond]", 22}, {"\[FilledSquare]", 27}} for the second example seems to produce roughly the same result as the first example. They are spaced farther apart, though. $\endgroup$ Commented Oct 2, 2014 at 0:35
  • $\begingroup$ I have to use the first sample though... I tried assigning option ImageSize to Graphics, such as Graphics[Disk[{0, 0}], ImageSize -> 22], but changing the value doesn't change the size of the symbols. $\endgroup$
    – Leonx
    Commented Oct 2, 2014 at 1:29
  • $\begingroup$ BTW, regarding the surrounding edge, we can remove it by supplying EdgeForm[] in Graphics, eg, Graphics[{EdgeForm[], Disk[{0, 0}]}] $\endgroup$
    – Leonx
    Commented Oct 2, 2014 at 2:06

2 Answers 2

2
$\begingroup$

There is no one-to-one equivalence because font glyphs and Graphics primitives are not rendered the same way. Essentially 22 in {"\[FilledCircle]", 22} is a font size whereas LegendMarkerSize is set as ImageSize which is in screen pixels. The issue then it to scale font size to fill a given pixel width which is a known difficult problem in Mathematica. See for example:

One observable difference is in the margin of each marker (font glyphs on the right):

enter image description here

Also note that the relative sizes (within a column above) are not the same; with the Graphics objects the orange square is larger than the blue diamond, whereas with the font glyphs these are apparently the same size.

If you describe your actual application that inspired this question I may have suggestions for improved workflow; otherwise I suggest you get used to using Graphics primitives if you want precise control of these things.

$\endgroup$
1
$\begingroup$

A graphical comment to Mr. Wizard's answer:

SwatchLegend[
 63,
 Range[3],
 LegendMarkers -> {
   Graphics[Disk[]],
   Graphics[Polygon[{{1, 0}, {0, 1}, {-1, 0}, {0, -1}}]],
   Graphics[Rectangle[]]}]

enter image description here

SwatchLegend[
  63,
  Range[3],
  LegendMarkers -> {{"\[FilledCircle]", #}, {"\[FilledDiamond]", #}, \ {"\[FilledSquare]", #}}] & 
[13.5]

enter image description here

Conclusion: There is no relationship. Don't use glyphs with LegendMarkers.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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