I have a list of triplets {{x1,y1,z1}, {x2,y2,z2}.....} and would like to plot $x$ vs. $y$, then $x$ vs. $z$. ListLinePlot will plot these if they were doublets, but how do I select pairs to plot?


closed as off-topic by C. E., happy fish, m_goldberg, MarcoB, Henrik Schumacher Apr 21 at 16:23

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." – C. E., happy fish, m_goldberg, MarcoB, Henrik Schumacher
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 7
    $\begingroup$ Look at the documentation page for the Part function. You'll want to use something like data[[All, {1,2}]] for {x,y} and data[[All, {1,3}]] for {x,z}. $\endgroup$ – user6014 Apr 20 at 18:09
  • $\begingroup$ Thank you -- I did try Part, but I'm still learning the fundamentals of Mathematica (so far, I love it!). I'll use your note as a template and come back with the results, when I give it another shot. Much appreciated! - Andy OK, so I tried it right away -- Yes, it does work. I was close, but it's not second nature yet. Thank you! I will return the favor to someone else..... $\endgroup$ – alaz Apr 20 at 21:11

Contrived data producing a list of 10 triples of the form {{1, y1, z1}, {2, y2, z2}, ...}.

SeedRandom[1]; data = Table[{i, Sequence @@ RandomReal[1., 2]}, {i, 10}];

Now we plot x & y and x & z.

ListLinePlot[{data[[All, ;; 2]], data[[All, ;; 3 ;; 2]]}]


ListLinePlot[{data[[All, {1, 2}]], data[[All, {1, 3}]]}]

Both display


Note: Look up Part and Span in the docs,


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