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

I have two sets of x,y coordinates, and want to plot them both on the same graph. With one set,

List1 $= \{ \{ x_1, y_1 \}, \{ x_2, y_2 \},\{ x_3, y_3 \}, \cdots \}$

I can use ListLinePlot[List1].

But with a second list,

List2 $= \{ \{ u_1, v_1 \}, \{ u_2, v_2 \},\{ u_3, v_3 \}, \cdots \}$

I assumed I'd be able to use something like ListLinePlot[List1,List2], but this seems reserved for when the lists have only one of the coordinates: $\{ x_1, x_2, x_3, \cdots\}$.

The data in List1 has to be connected via a line, as does the data in List2, but they mustn't be joined together (i.e. I can't amalgamate them into one list). Anyone know how I can plot both sets on the same graph?

share|improve this question
The answer is the third syntax form on the ListLinePlot doc page. If you have questions in the future, could you please check the reference pages first? – Sjoerd C. de Vries Mar 12 '12 at 0:24
@SjoerdC.deVries I did! I made the mistake of thinking the curly brackets outside each list $\{ \{ x_1, y_1 \}, \cdots \}$ were the same curly brackets as in the 3rd form of ListLinePlot in the documentation, so I was short of the outside set of brackets. – Calvin Mar 12 '12 at 22:30
Yeah, that is quite understandable. The docs have the habit of summarizing earlier syntax constructions that are being reused in forms later on into a single word (not formally defined). So, {{x1,y1},⋯} becomes list1. It happens all the time and it takes some getting used to it. Apologies if I sounded rude. – Sjoerd C. de Vries Mar 12 '12 at 22:36
@SjoerdC.deVries No worries, thank for your comment. Hopefully I'll get used to it soon :o) – Calvin Mar 14 '12 at 22:04
up vote 11 down vote accepted

Instead of ListLinePlot[ list1, list2 ] use ListLinePlot[ {list1, list2} ].

share|improve this answer
Awesome - thanks. Seems so obvious now! – Calvin Mar 11 '12 at 2:52
@Calvin To the best of my knowledge, every plotting function operates that way. So, if you need to plot multiple things on a single plot, just wrap them in a list. – rcollyer Mar 11 '12 at 2:55
One exception is the PairedXXXX set of functions. Although in that case it perhaps depends on your interpretation of "single plot". – Brett Champion Mar 11 '12 at 2:57

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.