# Creating a Number Line Continuum

In Wolfram, how can one create a plot similar to the following:

That is: a number-line like continuum with labeled points?

## 1 Answer

SeedRandom[77]
lst = RandomSample[Range[-10, 10, .25], 5];

ListPlot[MapThread[{Callout[#, Rotate[#[[1]], 90 Degree], Above,
LeaderSize -> 30, LabelStyle -> Directive[#2, 12],
CalloutMarker -> "Arrow", "CalloutStyle" -> #2]} &,
{Thread[{lst, 0}], ColorData[97] /@ Range[Length@lst]}],
PlotStyle -> PointSize[.015], Axes -> {True, False},
Ticks -> {Range[-10, 10], None},
PlotRange -> {{-10, 10}, Automatic},
PlotRangePadding -> Scaled[.1],
AxesStyle -> Arrowheads[{{-.05, 0}, {.05, 1}}]]


Update: Using custom Arrowheads to label the two directions of horizontal axis:

ListPlot[MapThread[{Callout[#, Rotate[#[[1]], 90 Degree], Above,
LeaderSize -> 30, LabelStyle -> Directive[#2, 12],
CalloutMarker -> "Arrow", "CalloutStyle" -> #2]} &,
{Thread[{lst, 0}], ColorData[97] /@ Range[Length@lst]}],
PlotStyle -> PointSize[.015], Axes -> {True, False},
Ticks -> {Range[-10, 10], None},
PlotRange -> {{-10, 10}, Automatic},
AxesStyle -> Arrowheads[{{-.05, 0}, {.05, 1},
{.05, 0,  Graphics @ Text[Style["negative direction", 16], {0, 0}, {1., 0}]},
{.05, 1, Graphics @ Text[Style["positive direction", 16], {0, 0}, {-1.1, 0}]}}],
PlotRangePadding -> Scaled[.1],
ImagePadding -> {{Scaled[.15], Scaled[.15]}, {None, Scaled[.05]}},
ImageSize -> 700]


Alternatively, add the axes labels using Epilog:

ListPlot[MapThread[{Callout[#, Rotate[#[[1]], 90 Degree], Above,
LeaderSize -> 30, LabelStyle -> Directive[#2, 12],
CalloutMarker -> "Arrow", "CalloutStyle" -> #2]} &,
{Thread[{lst,  0}], ColorData[97] /@ Range[Length@lst]}],
PlotStyle -> PointSize[.015], Axes -> {True, False},
Ticks -> {Range[-10, 10], None},
PlotRange -> {{-10, 10}, Automatic},
AxesStyle -> Arrowheads[{{-.05, 0}, {.05, 1}}],
PlotRangePadding -> Scaled[.1],
ImagePadding -> {{Scaled[.2], Scaled[.2]}, {None, Scaled[.05]}},
ImageSize -> 700,
Epilog -> {Text[Style["negative direction", 16], Offset[{-30, 0}, {-11, 0}], {1, 0}] ,
Text[Style["positive direction", 16], Offset[{30, 0}, {11, 0}], {-1, 0}]}]


• Is there a way to label the arrow heads on both side of the plot (i.e., the left one "negative direction" and the right one perhaps "positive direction")? Commented Aug 5, 2019 at 18:09
• @George, please see the update.
– kglr
Commented Aug 5, 2019 at 18:53
• The second method (using Epilog) doesn't work on my local version of Wolfram Desktop (I just see the number line w/o any text). Is this also the case on your machine? Commented Aug 10, 2019 at 3:49
• @George, I don't have the desktop version of v12. The pictures I posted are obtained using v12 on Wolfram Cloud.
– kglr
Commented Aug 10, 2019 at 4:11
• This is what I"m seeing. Commented Aug 10, 2019 at 14:00