7
$\begingroup$

I have a list of points that I plot with ListPlot.

I want all the points to have two different colors like in the picture

enter image description here

how can I do this with Mathematica?

$\endgroup$
  • $\begingroup$ Take a look at Disk. $\endgroup$ – Kuba Feb 11 at 19:22
10
$\begingroup$
data = Transpose@Range[{5, 5}];

You can create custom PlotMarkers with the desired shape:

marker = Graphics[{Red, Disk[{0, 0}, 1, {Pi/2, 3 Pi/2}], Blue, 
    Disk[{0, 0}, 1, {3 Pi/2, 5 Pi/2}]}];
ListLinePlot[data, PlotMarkers -> {marker, .1}, 
 PlotRangePadding -> Scaled[.1], PlotStyle -> Dashed]

enter image description here

Alternatively, you can use PieChart to create the desired markers:

pie = PieChart[{1, 1}, SectorOrigin -> {{Pi/2}, 0}, 
   ChartStyle -> {Red, Blue}, PlotRangePadding -> 0];
ListLinePlot[data, PlotMarkers -> {pie, .1}, 
 PlotRangePadding -> Scaled[.1], PlotStyle -> Dashed]

enter image description here

Yet another alternative is to post-process the output of ListLinePlot with Automatic markers to replace the markers with pie:

llp = ListLinePlot[data, PlotMarkers -> Automatic, 
   PlotRangePadding -> Scaled[.1], PlotStyle -> Dashed];
llp /. Inset[x_, p_] :> Inset[pie, p, Automatic, .3]

enter image description here

You can also use pie as the setting for ChartElements in BubbleChart after adding a third column to data:

BubbleChart[{##, 1} & @@@ data, ChartElements -> pie,
 Prolog -> ListLinePlot[data, PlotStyle -> Dashed][[1]]]

enter image description here

$\endgroup$

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.