# Plotting points on the horizontal line

I have list such as

list = {1, 5, 2, 6, 3,...}


and I need to plot the numbers from the list on a horizontal line such that there will be on a place on horizontal line which will correspond to the number itself plus all the previous numbers.

Using the above-mentioned list:

1 will be plotted at the place of number 1; 5 will be plotted at the place of number 6; 2 will be plotted at the place of number 8; 6 will be plotted at the place of number 14 etc.

list = {1, 5, 2, 6, 3};
NumberLinePlot[list]


NumberLinePlot[Accumulate@list]


ListPlot[Transpose[{list,Accumulate@list}]]


Update:

... on the horizontal axis, there would be instead of accumulated numbers, dates that correspond to to the accumulated number

... in case of one graph ... there are selected months on the horizontal.

list2 = RandomInteger[100, 50]; DateListPlot[
Transpose[{DayPlus[{1999, 1, 2}, #] & /@ Accumulate@list2, list2}],
FrameTicks -> {{{2000, 1}, {2001, 4}, {2002, 2}, {2002, 11},
{2003, 7}, {2003, 12}, {2004, 8}}, Automatic, Automatic, Automatic},
DateTicksFormat -> {"MonthName", "\n", "Year"}, ImageSize -> 600,
AspectRatio -> 1/4]


• Awesome, @kguler. You also made me realize that plot it in 2D will be better. Can I also ask you whether it can be done that on the horizontal axis, there would be instead of accumulated numbers, dates that correspond to to the accumulated number -> I have also a list of DateObjects -> e.g. if the accumulated number equals to 6, the date that is within 6 days from the first day in a list will appear on a horizontal line (or better, only just few of such a dates will appear otherwise it would not be possible to read it Apr 16, 2015 at 19:49
• @rabbit, maybe something like: DateListPlot[List/@Transpose[{DayPlus[Today,#]&/@Accumulate@list,list}],PlotMarkers->(Style[#,20]&/@list),ImageSize->500]?
– kglr
Apr 16, 2015 at 20:57
• which list in your code is the list with DateObjects (since I have the dates in separate list)? ...or maybe it would also suffice to add the dates manuály such as {{1999, 1, 2},{2000, 1, 2}}. Apr 17, 2015 at 6:13
• @rabbit3698741, DayPlus[Today,#]&/@Accumulate@list.
– kglr
Apr 17, 2015 at 6:29
• OK so i tried DateListPlot[ List /@ Transpose[{DayPlus[{1999, 1, 2}, #] & /@ Accumulate@list, list}], PlotMar‌​kers -> (Style[#, 20]&/@list), ImageSize -> 500], where list is the same list as mentioned in your main answer and it returns me: Unknown option PlotMar‌​kers... @kguler Apr 17, 2015 at 7:50
list = {1, 5, 2, 6, 3};
ListPlot[{#} & /@
Transpose[{Accumulate[list], Table[1, {Length[list]}]}],
PlotMarkers -> list, Axes -> {True, False}, AspectRatio -> 1/10]


• thanks! It also works. However, I realized that the solution given by kguler will be more appropriate for my needs @shrx. Apr 17, 2015 at 7:55
• @rabbit3698741 no problem, although I think my solution is more relevant to what you are asking. You should consider this when you decide to accept an answer (you can accept only one).
– shrx
Apr 17, 2015 at 12:46