iez
iez

Reputation: 1

Mathematica ListPlot two columns from the same table as (x,y) plot

I'm new to Mathematica, trying to ListPlot set of data having time in the first column and values in the columns 2 and 3.

t = Import["/.../time_deltas.csv", "CSV"]

{{11.1694,0.,0},       {11.1697,0.000275,0}, {11.1702,0.000495,0}, 
 {11.1702,0.000028,0}, {11.1702,1.*10^-6,0}, {11.1702,0.000033,0},
 {11.1707,0.000502,0}, {11.171,0.000314,0},  {11.171,4.*10^-6,0}, 
 {11.1711,0.000025,0}, {25.8519,0.000029,1}, {25.852,0.000049,1},
 {25.852,0.000032,1},  {25.8521,0.000031,1}, {25.8524,0.000388,1},
 {25.8524,1.*10^-6,1}, {25.8525,0.000051,1}, {25.8543,0.001852,1},
 {25.9342,0.079813,0},{25.9391,0.004914,0}}

Plotting a single point I expected that:

ListPlot[{t[[1,2,1]],t[[1,2,2]]}] 

Would plot a single point with x=11.169662 and y=0.000275. Instead it plots two points with x=1,2 and y=11.169662, 0.000275.

What am I doing wrong ?

Upvotes: 0

Views: 2993

Answers (1)

Chris Degnen
Chris Degnen

Reputation: 8655

You need to group the data into x-y pairs for each list plot, e.g.

u = {{#1, #2}, {#1, #3}} & @@@ t;
v = Transpose[u];
GraphicsColumn[{ListPlot[v[[1]]], ListPlot[v[[2]]]}]

v[[1]] shows the data pairs you expect:

{{11.1694, 0.}, {11.1697, 0.000275}, {11.1702, 0.000495}, ... }

Upvotes: 0

Related Questions