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 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?

share|improve this question
    
What is molefrac ? And why do you have so many and btw unbalanced parenthesis in the 1st line? –  Vitaliy Kaurov Apr 5 '13 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? –  partial81 Apr 5 '13 at 6:33
    
@partial81 bill s beat us both (and kguler) to that answer. :-) –  Mr.Wizard Apr 5 '13 at 6:35
    
Related, though with lists of different lengths: Elegantly pairing up mismatched lists. –  István Zachar Apr 5 '13 at 11:28

2 Answers 2

up vote 10 down vote accepted

How about:

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.

share|improve this answer
1  
+1 -- In the FrontEnd this is extremely concise: ListPlot[{molefrac, calibrationIndexOfRefraction}\[Transpose]] –  Mr.Wizard Apr 5 '13 at 6:34

Another possible solution:

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

or

ListPlot[{molefrac, calibrationIndexOfRefraction}//Thread]
share|improve this answer

Your Answer

 
discard

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.