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.

I got a matrix which looks the following and should be seen as a list of pairs with (x,y) coordinates:

test = {{0, 1, 2, 3}, {11000, 23940., 36880., 49820.}};

I'm trying to plot them with the following command:

ListLinePlot[test, PlotRange -> {{0, 4}, {0, 50000}}]

My problem: with the above commands I always get a plot that starts with 1 for the first x-coordinate instead of 0, then takes 2 instead of 1 for the second x-coordinate and so on.

All I want is to plot the points exactly as listed in test. As if I had a entered a list like {{1,2,3,4},{11000,23940,36880,49820}}, which I obviously didn't.

Can someone help me?

share|improve this question

closed as off-topic by Öskå, gpap, ubpdqn, Sjoerd C. de Vries, eldo Aug 26 at 14:14

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Öskå, gpap, ubpdqn, Sjoerd C. de Vries, eldo
If this question can be reworded to fit the rules in the help center, please edit the question.

Try plotting Thread@test. Is that what you need? –  mfvonh Aug 26 at 13:11
Related, possibly duplicate? –  Simon Woods Aug 26 at 13:54
Try plotting Transpose@test. Is that what you need? –  Sjoerd C. de Vries Aug 26 at 13:55

2 Answers 2

up vote 6 down vote accepted

Here is what you want to do:

ListLinePlot[Transpose[test], PlotRange -> {{0, 4}, {0, 50000}}]

Mathematica graphics

share|improve this answer
One single transpose and it's working perfectly fine, unbelievable. Sometimes I don't get the mathematica thinking..Thanks very much for your answer! –  Phily Aug 26 at 13:24
@Phily See the docs, second line: "ListLinePlot[{{x1,y1},{x2,y2},…}], plots a line through specific x and y positions.". –  Öskå Aug 26 at 13:25

Alternatively, you can use use the option DataRange

test = {{0, 1, 2, 3}, {11000, 23940., 36880., 49820.}};

ListLinePlot[test[[2]], DataRange -> {0, 3}]

enter image description here

share|improve this answer
@Yves Klett - I plotted test[[2]] rather than test to avoid plotting test[[1]]. –  Bob Hanlon Aug 26 at 13:51

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