# How to make a PlotMarker with two colors?

I have a very simple question. I'd like to display two points -- that currently appear on top of each other in a ListPlot -- as (replace them by) a single plot marker with two colours, one for each half of the marker, say upper/lower halves. Since I am using the default plot markers, I'm just after a disk of precisely the same size as the one from PlotMarkers -> Automatic with adjustable colours for the upper and lower halves. Then I can easily match the size and colours with the rest of my plot. How does one make this marker?

Here's a toy example to play around with: ListPlot[{Table[1/n,{n,10}],ConstantArray[1/10,10]}]. In this case I'd like the last point to have the first default colour (upper half) and second default colour (lower half).

• I noticed that any questions that start with "I have a simple question" are very rarely simple :-) That will require a lot of manual fiddling. Are you sure you can't change the size of one of the two data series so the underlying one still shows, or some other presentation change that can work within the existing framework? Can you include some sample data to play with? Sep 18 at 15:47
• I thought I can just use e.g. Show and add the point on top at the end. So it's just the marker that I need. But that's already a lot of work? In general I'd like the shapes and sizes of the markers of the two data series (containing the overlapping point) to be the same Sep 18 at 15:50
• Perhaps look at the PolygonMarkers resource function. The "neat examples" section contains an example of half-filled polygonal markers. Sep 18 at 15:59
• @MarcoB Added a simple example. Ooh, PolygonMarker looks promising, thanks for the pointer! Sep 18 at 16:08

You may draw a marker consisting of 2 half disks with the corresponding colors:

ListPlot[{Table[1/n, {n, 10}], ConstantArray[1/10, 10]},
Epilog -> {Blue, Disk[{10, 0.1}, {0.1, 0.008}, {0, Pi}], Orange, ,
Disk[{10, 0.1}, {0.1, 0.008}, {Pi, 2 Pi}]}] • That's quite decent. Actually just the Epilog -> {Blue, Disk[{10, 0.1}, {0.065, 0.005}, {0, Pi}] would more or less work, except that I had to fiddle around to get the size approximately right. Is there an easy way to get the dimension to match that of (half) the default plotmarker? Sep 18 at 16:41
• You could take a fraction of the PlotRange. Sep 18 at 17:20
• And do you happen to know what the default fraction of the PlotRange is? Sep 18 at 19:33
• Look at may plot. I used 0.1 in the x direction. This is 1/100. Sep 19 at 6:52

Here's an attempt using the PolygonMarkers resource function. The hfm function is adapted from the Neat Examples section of the documentation of that resource function.

sin = Table[{x, Sin[x]}, {x, 0, 1.5 Pi, Pi/9}];
line = Table[{x, x - 1.22}, {x, 0, 1.5 Pi, Pi/9}];

ClearAll[hfm]
hfm[name_String, side_String : "Right", size_ : 9] :=
Module[
{checkSide = If[side === "Right", Negative, Positive, Negative]},
Show[
ResourceFunction["PolygonMarker"][name, Offset@size, {FaceForm[None], Dynamic@EdgeForm[{CurrentValue["Color"], AbsoluteThickness, Opacity}]}],
ResourceFunction["PolygonMarker"][name, Offset@size, EdgeForm[None]] /. {x_?checkSide, y_?NumericQ} :> {0, y}
]
]

ListPlot[
{sin, line},
PlotMarkers -> {hfm["Circle", "Right"], hfm["Circle", "Left"]},
Joined -> True,
Frame -> True, Axes -> False,
PlotLegends -> PointLegend[{"sine", "line"}, LegendMarkerSize -> {40, 30}]
] • That's pretty good already! I'd like to keep the default markers everywhere except at the overlapping point, where want to superimpose the new extra marker showing both colours (and EdgeForm[Empty]). Sep 18 at 16:36

A possibility could be:

t = Table[{x, Sin[x]}, {x, 0, 2 π, π/10}];
m1 = Graphics[{
Orange, Disk[{0, 0}, Offset[{4, 4}], {0, \[Pi]}]
}
];

m2 = Graphics[{
Red, Disk[{0, -1}, Offset[{4, 4}], {\[Pi], 2 \[Pi]}]
}
];

ListPlot[{t, t}, PlotMarkers -> {m1, m2}, • I think that if intersections is all you want to show, then create a multicolor disk and use it in the Epilog.