So I have an xls file with 5 Collums and a few thusand rows. Now i want to get only 3 of the collums plot them over the number of rows and then put them in one single graphic. But it should be variable so if I have a diffrent table with more, less collums or want to choose diffrent collums I just have to adopt some variables

i := 2;
j := 1;
t = 3;
testtabele = 
  Import[NotebookDirectory[] <> "test.xls"];

Do[Liwind[i + j] = testtabele[[1 ;;, 3 ;;, i + j]], {j, t}] 

Do[Liwind[i + j] = Liwind[i + j]/1000, {j, t}]

Do[Print[ListLinePlot[Liwind[i + j]]], {j, t}]
(* Prints for every List one graph*)

Here are diffrent things I tried.

        {Liwind[i + j], Liwind[i + j],Liwind[i + j]}
     ],{j, 3}


Show[p[i + j], p[i + j + 1], p[i + j + 2]]

Hope someone can Help me with that

  • $\begingroup$ Just a helpful hint: you don't need Print if you use Table instead of Do. $\endgroup$
    – b3m2a1
    Dec 5, 2017 at 18:43

1 Answer 1


You just need to pass your data to ListLinePlot in the layout it expects, in this case it's the third form shown in the docs: ListLinePlot[{data1,data2,...}].

Each of the datai will correspond to a column you wish to plot, either just the y-values:

data1 = {y1,y2,y3,...}

or both x and y values:

data1 = {{x1,y1},{x2,y2},{x3,x3},...}

So if I generate some mock data with 5 columns and 221 rows:

mockData = Table[Sin[a x], {x, 0., 22, 0.1}, {a, 1, 5}];

The following will plot just columns 1, 3, and 4:

ListLinePlot[Transpose[mockData[[;; , cols]]], 
 PlotLegends -> ("Column " <> ToString[#] & /@ cols)]

enter image description here

Have a look at what mockData[[;; , cols]] returns and see why theTranspose helps.

  • $\begingroup$ thanks for the fast answer if i understand it correct my loop gives me the diffrent data1, data2, ... only with y cordinates But if i try then ListLinePlot[{data1,data2,...}] i only get back that datai are not list of numbers or pairs your code looks intteresing but after i copied to a new notebook it doesn't showed me anything is there a problem or diffrent in the version 11? $\endgroup$ May 9, 2017 at 14:49
  • $\begingroup$ I forgot to specify cols, which should be {1,3,4} in my example. I've edited it in. $\endgroup$ May 9, 2017 at 15:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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