'PlotLegend' não exibe a cor correta do símbolo

Oct 15 2020

Estou traçando alguns pontos de dados com uma legenda, mas PlotLegendnão produz a mesma cor que os pontos têm. Onde está o erro?

Aqui está o resultado que obtenho: [1]: https://i.stack.imgur.com/s5yga.png

ListPlot[{{0.4, 38}, {0.5,   15}, {0.6, 10}},
 Frame -> True,
 FrameLabel -> {"a", "b"},
 PlotMarkers -> {
   Graphics[{EdgeForm[Directive[Thick, Blue]], White, Rectangle[]},ImageSize -> (15)]},
  PlotRange -> {{0.3, 0.7}, {0, 100}},
 PlotRangePadding -> {0.05, 2},
 PlotLegends -> 
  Placed[PointLegend[{"data"}, LegendMarkerSize -> 14, 
    LabelStyle -> {FontSize -> 18, FontFamily -> "Arial", 
      Black}], {0.165, 0.215}]]


 

Respostas

4 kglr Oct 15 2020 at 19:10

Bordas acinzentadas em marcadores de legenda são causadas pela configuração padrão:

Legending`LegendDump`$DefaultMarkerStyle
EdgeForm[Directive[Opacity[0.3`], GrayLevel[0]]]

Você pode corrigir o problema de três maneiras diferentes:

1. Use em EdgeForm[Directive[Thick, Opacity[1], Blue]]vez de EdgeForm[Directive[Thick, Blue]]para obter

2. Adicione a opção BaseStyle -> EdgeForm[Opacity[1]]de PointLegend:

ListPlot[{{0.4, 38}, {0.5, 15}, {0.6, 10}}, Frame -> True, 
 FrameLabel -> {"a", "b"}, 
 PlotMarkers -> {Graphics[{EdgeForm[Directive[Thick, Blue]], White, 
     Rectangle[]}, ImageSize -> (15)]}, 
 PlotRange -> {{0.3, 0.7}, {0, 100}}, PlotRangePadding -> {0.05, 2}, 
 PlotLegends -> 
  Placed[PointLegend[{"data"}, BaseStyle -> EdgeForm[Opacity[1]], 
    LegendMarkerSize -> 14, 
    LabelStyle -> {FontSize -> 18, FontFamily -> "Arial", 
      Black}], {0.165, 0.215}]]

3. Defina o valor de Legending`LegendDump`$DefaultMarkerStylepara Opacity[1]:

Legending`LegendDump`$DefaultMarkerStyle = Opacity[1]

ListPlot[{{0.4, 38}, {0.5, 15}, {0.6, 10}}, Frame -> True, 
 FrameLabel -> {"a", "b"}, 
 PlotMarkers -> {Graphics[{EdgeForm[Directive[Thick, Blue]], White, 
     Rectangle[]}, ImageSize -> (15)]}, 
 PlotRange -> {{0.3, 0.7}, {0, 100}}, PlotRangePadding -> {0.05, 2}, 
 PlotLegends -> 
  Placed[PointLegend[{"data"}, LegendMarkerSize -> 14, 
    LabelStyle -> {FontSize -> 18, FontFamily -> "Arial", 
      Black}], {0.165, 0.215}]]