1
$\begingroup$

I am plotting some experimental results with ListPlot and use customly made plot markers. To be specific, here is my data:

    lst1 = {{0.006`, 45.67`}, {0.029`, 51.46`}, {0.052`, 55.08`}, {0.072`,
     52.47`}, {0.114`, 57.37`}, {0.092`, 62.16`}, {0.141`, 65.5`}};
lst2 = {{0.007`, 44.01`}, {0.03`, 49.75`}, {0.053`, 54.21`}, {0.073`, 
    52.51`}, {0.093`, 56.87`}, {0.115`, 61.31`}, {0.142`, 60.77`}};
lst3 = {{0.007`, 45.33`}, {0.03`, 49.89`}, {0.053`, 52.54`}, {0.073`, 
    50.45`}, {0.093`, 54.22`}, {0.115`, 59.56`}, {0.142`, 58.39`}};
lst4 = {{0.006`, 36.`}, {0.047`, 39.03`}, {0.03`, 41.68`}, {0.068`, 
    46.34`}, {0.085`, 51.36`}, {0.103`, 57.87`}, {0.122`, 
    67.07`}, {0.141`, 63.66`}};
lst5 = {{0.004`, 35.13`}, {0.027`, 38.04`}, {0.044`, 40.25`}, {0.065`,
     44.38`}, {0.082`, 49.11`}, {0.102`, 55.04`}, {0.121`, 
    63.01`}, {0.139`, 62.53`}};
lst6 = {{0.007`, 34.84`}, {0.03`, 37.58`}, {0.047`, 39.97`}, {0.068`, 
    44.28`}, {0.086`, 49.42`}, {0.104`, 56.7`}, {0.123`, 
    64.07`}, {0.141`, 59.29`}};

Here are my markers:

vertexUpOpenTriangle = 
  Graphics[{EdgeForm[Directive[Thickness[0.2], Darker@Blue]], White, 
    Polygon[{{1, 0}, {0, Sqrt[3]}, {-1, 0}}]}, ImageSize -> 8];
openSquare = 
  Graphics[{EdgeForm[Directive[Darker[Blue], Thickness[0.2]]], 
    Darker[Blue], Rectangle[]}, ImageSize -> 8];
vertexUpFilledTriangle = 
  Graphics[{Darker[Blue], Polygon[{{1, 0}, {0, Sqrt[3]}, {-1, 0}}]}, 
   ImageSize -> 8];
diamondOpen = 
  Graphics[{EdgeForm[Directive[Thickness[0.2], Darker[Red]]], White, 
    Polygon[Table[{Cos[Pi k/2], Sin[Pi k/2]}, {k, 4}]]}, 
   ImageSize -> 8];
vertexDownOpenTriangle = 
  Graphics[{EdgeForm[Directive[Thickness[0.2], Darker[Red]]], White, 
    Polygon[{{1, 0}, {0, -Sqrt[3]}, {-1, 0}}]}, ImageSize -> 8];
filledSquare = Graphics[{Darker[Red], Rectangle[]}, ImageSize -> 8];

and here is my ListPlot function:

 ListPlot[{lst1, lst2, lst3, lst4, lst5, lst6}, 
 PlotMarkers -> {vertexUpOpenTriangle, openSquare, 
   vertexUpFilledTriangle, diamondOpen, vertexDownOpenTriangle, 
   filledSquare}, Frame -> True, 
 FrameLabel -> {Style["Height along the middle line (m)", 16], 
   Style["Temperature (\[Degree]C)", 16]}, ImageSize -> 400, 
 GridLines -> Automatic, GridLinesStyle -> Gray, 
 PlotLegends -> 
  Placed[PointLegend[{"Corrected 1", "Corrected 2", "Corrected 3", 
     "Control 1", "Control 2", "Control 3", "(a) 3", "(b) 3", 
     "(c) 3"}], Right]]

All this works, except from a minor, but boring peculiarity. In the plot the markers are shown in a deep blue and deep red (as it is desired). However, in the legend (to the right of the plot) the filled markes show in the desired deep red and blue colors, while those that are not filled are astonishingly light blue and pink.

enter image description here

Any idea of how to repair that?

$\endgroup$
3
  • $\begingroup$ Did you try to make a Legend using Legended? This built-in PlotLegend uses the Plot-related styles and, therefore, can cause this wrong coloring $\endgroup$
    – Rom38
    Aug 28, 2017 at 9:50
  • $\begingroup$ @Alexei Note that your triangle markers are positioned incorrectly: Polygon[{{1, 0}, {0, Sqrt[3]}, {-1, 0}}] // RegionCentroid returns {0, 1/Sqrt[3]} instead of {0, 0}. See discussion here. Also you can try my package. $\endgroup$ Aug 28, 2017 at 10:09
  • $\begingroup$ @ Alexey Popkov You are right, I did not think about it. Not important in my case, since the experimental error is larger, but still. Thank you. $\endgroup$ Aug 28, 2017 at 10:15

1 Answer 1

3
$\begingroup$

I'd call it a bug in typesetting of PointLegend:

PointLegend[{Red}, {"Test"}, 
  LegendMarkers -> {{Graphics[{EdgeForm[Directive[Red]], Red, 
       Disk[]}], Automatic}}] // Magnify[#, 5] &

enter image description here

Opacity is injected to EdgeForm without asking.

A workaround is to use explicit edge from opacity specification for your plot markers e.g.:

EdgeForm[Directive[Thickness[0.2], Darker@Blue, Opacity@1]]

enter image description here

$\endgroup$
1
  • $\begingroup$ Thank you very much, this helps. $\endgroup$ Aug 28, 2017 at 10:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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