# Change the inner color of markers

I would like to have a marker with white as its inner color, to be able to make this kind of graph:

If I use PlotMarkers -> Style["\[FilledSquare]", White], it changes both the inner color + border color but not the inner color only.

If I use PlotMarkers -> Style["\[EmptySquare]", White], the line of the curve goes above the marker.

How could I achieve that?

-
PlotMarkers->Graphics[...] as in here – Timothy Wofford Jul 29 '14 at 14:58

In Version 10 you can use the PlotTheme "OpenMarkersThick":

data = Table[{x, x^k}, {k, 1, 4}, {x, 0, 1, 0.1}]

ListLinePlot[data, PlotTheme -> {"OpenMarkersThick", "LargeLabels"},
PlotLegends -> {x, x^2, x^3, x^4}]


-
PlotTheme looks powerful. Will try it as soon as Mathematica 10 is downloaded! – Sulli Jul 29 '14 at 18:50

\[FilledSquare] is a font glyph and you cannot color parts of it.

I believe you need to draw your markers with Graphics primitives. For example:

square[in_, out_: Black, size_: 12] :=
Graphics[{in, EdgeForm[{AbsoluteThickness[2], out}], Rectangle[]},
ImageSize -> size]

data = {{1, 2, 3, 5, 8}, {2, 3, 6, 9, 10}, {4, 5, 7, 10, 12}};

ListLinePlot[data,
PlotMarkers -> square /@ {Red, Green, Blue}
]


ListLinePlot[data,
PlotMarkers -> square @@@ {{Yellow, Red}, {White, Blue}, {Black, Pink}}
]


Update: proof that this method can easily be used for markers of arbitrary shape.

Generic marker function:

marker[prim_, opts___][in_: White, out_: Black, size_: 13] :=
Graphics[{in, EdgeForm[{AbsoluteThickness[2], out}], prim},
opts, ImageSize -> size]


Shapes:

square  = marker @ Rectangle[];
circle  = marker @ Disk[];
diamond = marker @ Polygon[{{0, 1}, {1, 2}, {2, 1}, {1, 0}}];
triangle =
marker[
Polygon[{{1, 0}, {0, Sqrt[3]}, {-1, 0}}],
AlignmentPoint -> {0, 1/Sqrt[3]}
];


Plot:

SeedRandom[12]

ListLinePlot[
Accumulate /@ RandomReal[3, {4, 10}] {1, 2, 3, 4},
PlotMarkers ->
{square[], circle[Yellow], diamond[Brown, Pink], triangle[Magenta, Purple]},
PlotLegends -> Automatic
]


-
Thanks Öskå. :-) – Mr.Wizard Jul 29 '14 at 15:06
@eldo You could use Primitives to produce any shape you like. Unlike other answers this one addresses the question in the Title: change the inner color of markers, not merely making centers white. (I wasn't aware of the theme "OpenMarkersThick" when I wrote this answer or surely would have included it.) I expect that chuy will earn the Accept but I don't think this is a bad answer. – Mr.Wizard Jul 29 '14 at 22:54
Your implementation of the triangle plot markers is incorrect as well as @eldo's: the center of the triangle is located on 1/3 of its height, not 1/2 as in your implementation. See here. – Alexey Popkov Jul 31 '14 at 12:23
Note that plot markers are aligned according to the AlignmentPoint option of Graphics. So if you add into your current triangle specification AlignmentPoint -> {0, 1/Sqrt[3]} you will get correct placement of the triangles. This value can be found via RegionCentroid@Polygon[{{1, 0}, {0, Sqrt[3]}, {-1, 0}}]. Of course for the other shapes in your answer this option should be different. – Alexey Popkov Jul 31 '14 at 15:12
@Alexey That is not what my code is doing. (Or at least not what I intend.) I changed the definition to marker[prim_, opts___] to pass options to Graphics. Sorry to disappoint. :-/ – Mr.Wizard Jul 31 '14 at 16:33

You could build your own PlotMarkers

ngon[p_, q_] :=
Polygon[Table[{Cos[2 Pi k q/p], Sin[2 Pi k q/p]}, {k, p}]]

g1 = Graphics[{EdgeForm[Black], White, Disk[{0, 0}, 1]}];
g2 = Graphics[{EdgeForm[Black], White, Rectangle[{1, 1}]}];
g3 = Graphics[{EdgeForm[Black], White, ngon[4, 1]}];
g4 = Graphics[{EdgeForm[Black], White, Polygon[{{1, 0}, {0, Sqrt[3]}, {-1, 0}}]}];

ListLinePlot[Table[n^(1/p), {p, 4}, {n, 10}],
Filling -> Axis,
PlotLegends -> Automatic,
PlotMarkers -> Table[{s, 0.05}, {s, {g1, g2, g3, g4}}]]


-
Note that the triangle plot markers are placed incorrectly in this answer: the center of the triangle is located on 1/3 of its height, not 1/2. See here. – Alexey Popkov Jul 31 '14 at 12:36