2
$\begingroup$

I want to generalize this plotting command:

Show[ListLinePlot[data1[[All, {1, #}]] & /@ columnlist]

which takes a table “data1”, defined as:

table1lines = RandomInteger[{3, 7}];
data1 = RandomReal[1, {table1lines, 5}]

(so I do not know the number of lines in advance) and plots graphs of all data from the first column against all data in columns given by “columnlist”, e.g.:

columnlist={2,3}

This works perfectly. Now I have a table data2 of a different structure, starting from the second column, each column consists of a list of real numbers (the same amount on each line), instead of just one number as before (actually I get it as a solution of Eigensystem):

dimension = RandomInteger[{3, 7}];
matrix = RandomReal[1, {dimension, dimension}]
data2=Re[Transpose[Eigensystem[N[matrix]]]]

so the second column, unlike the first one, in table "data2" is a list. I want to plot all data from the first column against all data on positions one to N from column 2 (so I will have N graphs in the plot). How to achieve this?

$\endgroup$
  • $\begingroup$ @Kuba Sorry, I don't get it, could you please modify my example using your solution? $\endgroup$ – wondering Nov 29 '14 at 9:18
  • $\begingroup$ @Kuba Data? As I wrote, we have a table "result", each row has the structure mentioned above, so sth. like: Table[{a[i], {b1[i], b2[i], b3[i]}}, {i, 1, imax}]. (And I don't know how big imax is.) $\endgroup$ – wondering Nov 29 '14 at 9:53
  • $\begingroup$ Please help us to help you and provide an actual example of your data in the question. $\endgroup$ – rhermans Nov 29 '14 at 11:14
  • $\begingroup$ @rhermans I changed the question, is this sufficient? $\endgroup$ – wondering Nov 29 '14 at 17:45
3
$\begingroup$
ListLinePlot@Table[
  Transpose[{data2[[All, 2, k]], data2[[All, 1]]}]
  , {k, Length[data2[[1, 2]]]}
  ]

or

ListLinePlot@Array[
 Transpose[{data2[[All, 2, #]], data2[[All, 1]]}] &
 , Length[data2[[1, 2]]]
 ]
$\endgroup$
4
$\begingroup$

I'm not sure if this is what you want but I used Thread to solve your problem:

dimension = RandomInteger[{3, 7}];
matrix = RandomReal[1, {dimension, dimension}];
data2 = Re[Transpose[Eigensystem[N[matrix]]]];
data2 // Grid

Mathematica graphics

processedData = Thread /@ data2 // Transpose;
processedData // Grid

Mathematica graphics

processedData // ListLinePlot

Mathematica graphics

$\endgroup$
  • $\begingroup$ That would work too, thanks! $\endgroup$ – wondering Nov 29 '14 at 19:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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