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.

A very simple question. I have a data table with three columns. how can i plot column 1 vs column 3 using ListPlot?

thx in advance

share|improve this question

closed as too localized by Ajasja, Yves Klett, Szabolcs, Sjoerd C. de Vries, Artes Jan 22 '13 at 17:33

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

    
Duplicate ? mathematica.stackexchange.com/questions/14884/… –  image_doctor Jan 22 '13 at 13:25
    
my list looks like this t={{14., 14.1, 14.2, 14.3, 14.4, 14.5, 14.6, 14.7, 14.8, 14.9, 15.}, {14., 14.1, 14.2, 14.3, 14.4, 14.5, 14.6, 14.7, 14.8, 14.9, 15.}, {16., 16.1, 16.2, 16.3, 16.4, 16.5, 16.6, 16.7, 16.8, 16.9, 17.}}. ListPlot[{t[[1]],[[3]]}] doesnt gives me column1Vscolumn3 ! :/ –  Darwin Jan 22 '13 at 13:35
    
Take a look at Transpose. –  Andy Ross Jan 22 '13 at 13:45
    
You need {t[[1]], t[[3]]} to take the first and third element. From this (see @AndyRoss), you'll need to make the pairs (x,y) to be plotted. –  b.gatessucks Jan 22 '13 at 13:46
    
Help can be found here –  cormullion Jan 22 '13 at 13:50

2 Answers 2

up vote 1 down vote accepted

The usual way to convert two sets of coordinates into one set of coordinate pairs in Mathematica is to use Transpose:

x = Range[10]
y = Range[1,20,2]

pairs = Transpose[{x,y}]

This might not feel intuitive if you are new to Mathematica.

For your data you could use either

ListPlot[Transpose[t][[All, {1,3}]]]

or

ListPlot[Transpose[ t[[{1,3}]] ]]
share|improve this answer
    
thanks belisarius and Szabolcs your suggestions worked for me –  Darwin Jan 23 '13 at 9:24

The meaning of "vs" in your question has two possible interpretations:

t = {{14., 14.1, 14.2, 14.3, 14.4, 14.5, 14.6, 14.7, 14.8, 14.9, 15.}, 
    {14., 14.1, 14.2, 14.3, 14.4, 14.5, 14.6, 14.7, 14.8, 14.9,  15.}, 
    {16., 16.1, 16.2, 16.3, 16.4, 16.5, 16.6, 16.7, 16.8, 16.9,  17.}};

ListLinePlot[Transpose[t][[{1, 3}]], AxesOrigin -> {0, 13}]

Mathematica graphics

Or:

ListLinePlot@Transpose[Transpose[t][[{1, 3}]]]

Mathematica graphics

share|improve this answer
    
i mean column1 being the x-axis and column3 being the y axis –  Darwin Jan 22 '13 at 15:38
    
@Darwin That is the second plot in my answer –  belisarius Jan 22 '13 at 16:29

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