# ListPlot problem

I have the following example:

x = {1, 2, 3, 4}
y = {{1, 2, 3, 4}, {2, 3, 4, 5}, {3, 4, 5, 6}, {4, 5, 6, 7}}


Now I can plot:

ListPlot[{Transpose[{x, y[[1]]}], Transpose[{x, y[[2]]}],
Transpose[{x, y[[3]]}], Transpose[{x, y[[4]]}]}]


How can this be simplified?

• Have you tried Map to avoid typing the same thing four times?? May 27, 2016 at 13:32
• Map[(Transpose[{x, #}]) &, y] ?
– mrz
May 27, 2016 at 13:32
• Yes, or just Transpose[{x,#}]& /@ y if you find that more readable. May 27, 2016 at 13:33
• With your x use the default: ListPlot[y] May 27, 2016 at 17:27
• @Bob Hanson: For my analysis in general x is not a list of of consecutive integers.
– mrz
May 28, 2016 at 7:23

If you want to simplify generating the input these are simpler ways:

x = Range[4];
y = Partition[ Range[7], 4, 1];


then you can use Inner:

z = Inner[List, x, y, List];


and finally

ListPlot[z]


Instead of playing with Partition and Range you can generate the input of ListPlot with Table:

z = Table[{i, i + k - 1}, {k, 4}, {i, 4}];


or even better with Array:

z = Array[{#2, #2 + #1 - 1} &, {4, 4}]


The simplest approach would make use of the Front - end shorthands for Transpose (esc tr esc) (see e.g. Add a vector to a list of vectors) and Map (/@) e.g.