NumberLinePlot: How to make the 3rd list (c) appears with “black crosses” or “void circles”?

a = {1, 2, 5, 2}
b = {2}
c = {1.75, 2.88, 3.25}
NumberLinePlot[{a, b, c}, PlotStyle -> Directive[PointSize[0.032]]]

I thought about PlotMarkers or PlotStyle, but no good results.

=================

=================

1 Answer
1

=================

NumberLinePlot is different in that the plot symbols actually mean something. A closed point means the data point is included, and an open point means the point is excluded (this is used in open intervals). Hence, it doesn’t make sense to use other symbols haphazardly.

If you just want to plot some symbols you can add some graphics yourself. The result of a NumberLinePlot is just a Graphics object which you can change using the usual methods (ReplaceAll and the like) or to which you can add stuff:

a = {1, 2, 5, 2};
b = {2};
c = {1.75, 2.88, 3.25};
g = NumberLinePlot[{a, b, c}, PlotStyle -> Directive[PointSize[0.032]]];

g // InputForm

(* Graphics[{{RGBColor[0.24720000000000014, 0.24, 0.6], PointSize[Medium],
Directive[RGBColor[0.368417, 0.506779, 0.709798], AbsoluteThickness[1.6], PointSize[0.032]],
{{Point[{1, 1}]}, {Point[{2, 1}]}, {Point[{5, 1}]}, {Point[{2, 1}]}}},
{RGBColor[0.6, 0.24, 0.4428931686004542], PointSize[Medium],
Directive[RGBColor[0.880722, 0.611041, 0.142051], AbsoluteThickness[1.6], PointSize[0.032]],
{{Point[{2, 2}]}}}, {RGBColor[0.6, 0.5470136627990908, 0.24], PointSize[Medium],
Directive[RGBColor[0.560181, 0.691569, 0.194885], AbsoluteThickness[1.6], PointSize[0.032]],
{{Point[{1.75, 3}]}, {Point[{2.88, 3}]}, {Point[{3.25, 3}]}}}}, AxesLabel -> {None}, Ticks -> {Automatic, Automatic}, FrameTicks -> {{Automatic, Automatic}, {Automatic, Automatic}},
PlotRange -> {{1., 5.}, {0, 3}}, PlotRangePadding -> {{Scaled[0.1], Scaled[0.1]}, {0, 1}},
AspectRatio -> 3/(10*GoldenRatio), AxesOrigin -> {Automatic, Automatic}, Axes -> {True, False},
ImagePadding -> All, {}] *)

Let’s define a cross primitive:

cross[{x_, y_}, d_] :=
Line[{{{x – d/2, y – d/2}, {x + d/2, y + d/2}}, {{x – d/2, y + d/2}, {x + d/2, y – d/2}}}]

Replace the third data set:

g[[1, 3]] = g[[1, 3]] /.
Point[{x_, y_}] :> Inset[Graphics@cross[{0, 0}, 1], {x, y}, {0, 0}, .1]

g

Note I used Inset so that the extreme AspectRatio setting does not distort the cross symbol.

  

 

@sjoerd-c-de-vries thank you. It´s a solution, but sometimes Mathematica is so complicated for little things that seems close to incredible.
– Mika Ike
Aug 7 ’15 at 12:40