Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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
add comment

1 Answer 1

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

Edit

Also

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. –  Feanor Nov 2 '13 at 3:28
add comment

Your Answer

 
discard

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.