Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Apologies if the question is too basic; I've searched the manual and the web but couldn't find a solution.

I would like to present some data on a discrete plot. The data is divided into $K$ series or numbers, $y_{k,1}, y_{k,2},\dots, y_{k,r_k}$ (with length $r_k$ depending on $k$, but is small). I would like to plot points corresponding to numbers in one series on a vertical line corresponding to the series. So, on the line ${x=1}$, one unit left of the $y$-axis, I would like to place all the points $y_{1,1}, y_{1,2},\dots, y_{1,r_1}$; then on the line ${x=2}$ I would like to place all the points $y_{2,1}, y_{2,2},\dots, y_{1,r_2}$; and so on. Thus, the points I need on the plot have coordinates $(i,y_{k,i})$. I'm fairly sure Mathematica has something like this as a built in type of plot, but I can't find it. Any help will be appreciated.

share|improve this question
up vote 10 down vote accepted

Build a sample list

b = Table[RandomReal[{0, 1}, k], {k, 8}]

Plot it:

ListPlot@MapIndexed[Function[{elem, idx}, {idx[[1]], #} & /@ elem], b]

Mathematica graphics



ListPlot@MapIndexed[Function[{elem, idx}, {idx[[1]], elem}], b, {2}]

And this is another way, without using MapIndexed[]

ListPlot@MapThread[Thread[{#2, #1}] &, {b, Range@Length@b}]
share|improve this answer
Thank you! That's exactly what I needed. – Jakub Konieczny Nov 2 '13 at 3:28

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.