# Better method for creating a tuple out of two lists

I just combined two lists using this method

molefrac = {1., 0.787402, 0.478927, 0.282592, 0.}
calibrationIndexOfRefraction = {1.440, 1.421, 1.395, 1.380, 1.351}
Partition[Riffle[molefrac, calibrationIndexOfRefraction], 2]

{{1., 1.44}, {0.787402, 1.421}, {0.478927, 1.395}, {0.282592, 1.38}, {0., 1.351}}


The purpose of this was to prepare the lists to be plotted using ListPlot. Is there some way to use ListPlot directly (or something more functional) to do this without going through all the extra steps?

• What is molefrac ? And why do you have so many and btw unbalanced parenthesis in the 1st line? Apr 5, 2013 at 6:20
• Why don't you use newList = Transpose[{molefrac, calibrationIndexOfRefraction}]. You will get the same result as above on a more straightforward way. This can be plotted easily with ListPlot[newList]. Or do I misunderstand your question? Apr 5, 2013 at 6:33
• @partial81 bill s beat us both (and kguler) to that answer. :-) Apr 5, 2013 at 6:35
• Related, though with lists of different lengths: Elegantly pairing up mismatched lists. Apr 5, 2013 at 11:28

ListPlot[Transpose[{molefrac, calibrationIndexOfRefraction}]]


You can look at the help file for ListPlot to see the plotting options to make it look the way you wish.

• +1 -- In the FrontEnd this is extremely concise: ListPlot[{molefrac, calibrationIndexOfRefraction}\[Transpose]] Apr 5, 2013 at 6:34

Another possible solution:

ListPlot[Thread[List[molefrac, calibrationIndexOfRefraction]]]


or

ListPlot[{molefrac, calibrationIndexOfRefraction}//Thread]