1
$\begingroup$

Consider the following input which should give a legend with a red rectangle and a black frame:

SwatchLegend[{Red}, {"A"}, LegendMarkers -> {Graphics[{EdgeForm[
  Directive[Black, Thickness[0.3]]], Rectangle[]}]},  LegendMarkerSize -> 80]

Using Mathematica 10.0.2 on linux I get:

enter image description here

Clearly, this is not the desired edge for the rectangle. Is this a bug or am I missing something?

Note: A simple workaround in this case is to draw a "frame" by adding a second rectangle behind the one I want that can act as a frame.

$\endgroup$
3
  • $\begingroup$ I don't see a question here. What are asking us to do for you? $\endgroup$
    – m_goldberg
    Commented Mar 19, 2016 at 21:53
  • $\begingroup$ Nothing, I just want to know whether this is a bug or not. $\endgroup$
    – JeffDror
    Commented Mar 19, 2016 at 21:53
  • 1
    $\begingroup$ I don't think it's a bug. I think the edge is drawn somewhat transparent; i.e., with an opacity less than 1. $\endgroup$
    – m_goldberg
    Commented Mar 19, 2016 at 22:01

2 Answers 2

2
$\begingroup$

Is this what you were expecting?

SwatchLegend[{Red}, {"A"}, 
  LegendMarkers -> 
    {Graphics[{EdgeForm[Directive[Black, Thickness[0.3], Opacity[1]]], Rectangle[]}]}, 
  LegendMarkerSize -> 80]

swatch

$\endgroup$
1
  • $\begingroup$ Awesome, thanks! I wonder why SwatchLegend changes the opacity of the edge... $\endgroup$
    – JeffDror
    Commented Mar 19, 2016 at 22:02
0
$\begingroup$

What you are seeing is the effect of default marker style for legend markers:

Legending`LegendDump`$DefaultMarkerStyle

 EdgeForm[Directive[Opacity[0.3], GrayLevel[0]]]

If you like, you can reset the default edge opacity to Opacity[1]:

Legending`LegendDump`$DefaultMarkerStyle = EdgeForm[Opacity[1]];

SwatchLegend[{Red}, {"A"}, LegendMarkers -> {Graphics[{EdgeForm[
  Directive[Black, Thickness[0.3]]], Rectangle[]}]},  LegendMarkerSize -> 80]

enter image description here

$\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.