8
$\begingroup$

If I create this plot

Data1 = Table[{X, X}, {X, 1, 10}];
Data2 = Table[{2 X, X}, {X, 1, 10}];
ListPlot[{Data1, Data2},
 PlotMarkers -> {{Graphics[Circle[]], 
    15}, {Graphics[{EdgeForm[{Thick, Black}], FaceForm[], 
      Rectangle[]}], 13.96}},
 PlotLegends -> {"1,", "2"},
 PlotStyle -> {Black, Black}]

the circle in the legend appears black as I want it to. However the rectangle is gray. If I choose Green as the second argument of EdgeForm, both the symbols in the plot and the symbol in the legend shows as green. How do I make Mathematica show a proper black icon in the legend?

$\endgroup$
2
  • 1
    $\begingroup$ You may be interested in the PolygonPlotMarkers package: mathematica.stackexchange.com/a/85094/12 $\endgroup$
    – Szabolcs
    Jan 8, 2020 at 11:38
  • $\begingroup$ Thank you for the idea! I wish I would have known about this, before setting all of my markers manually. $\endgroup$
    – camileri
    Jan 8, 2020 at 12:02

1 Answer 1

9
$\begingroup$

This is a bit tricky. The reason why the rectangle appears grey instead of black (even though you explicitly set Black) is that by default the legend generator adds an EdgeForm directive that lowers opacity. If you explicitly set the opacity as well, EdgeForm[Opacity[1]], either in the definition of your marker or in the PlotStyle, it will work as you required.

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