# On plotting multiple lists

I have four lists as given below:

 l1 = {r1 -> 0.1, r2 -> 0.3, r3 -> 0.1, r4 -> 1.0, r5 -> 0.3,
r6 -> 0.1};
l2 = {r1 -> 0.3, r2 -> 0.9, r3 -> 0.5, r4 -> 0.1, r5 -> 0.2,
r6 -> 0.2};
l3 = {r1 -> 0.4, r2 -> 0.1, r3 -> 0.2, r4 -> 0.2, r5 -> 0.7,
r6 -> 0.3};
l4 = {r1 -> 0.5, r2 -> 0.63, r3 -> 0.4, r4 -> 0.4, r5 -> 0.5,
r6 -> 0.4};


Is there an easy way to show how (r1, r2,r3,r4, r5) change respect to r6 ? I am in practice, dealing with large number of such lists, but the variables are just six.

Clear["Global*"];
l1 = {r1 -> 0.1, r2 -> 0.3, r3 -> 0.1, r4 -> 1.0, r5 -> 0.3,
r6 -> 0.1};
l2 = {r1 -> 0.3, r2 -> 0.9, r3 -> 0.5, r4 -> 0.1, r5 -> 0.2,
r6 -> 0.2};
l3 = {r1 -> 0.4, r2 -> 0.1, r3 -> 0.2, r4 -> 0.2, r5 -> 0.7,
r6 -> 0.3};
l4 = {r1 -> 0.5, r2 -> 0.63, r3 -> 0.4, r4 -> 0.4, r5 -> 0.5,
r6 -> 0.4};

lists = {l1, l2, l3, l4};
plots = Transpose[{r6 /. lists, # /. lists}] & /@ {r1, r2, r3, r4, r5};
ListLinePlot[plots]


• Thanks, @Syed, could you explain here this step in words : Transpose[{r6 /. lists, # /. lists}] & /@ {r1, r2, r3, r4, r5} May 29, 2023 at 7:58
• Remove the semicolon at the end to see what plots looks like. Here /@ is the Map command. So we create tuples for each of the point to be plotted in the list changing with respect to r6.
– Syed
May 29, 2023 at 8:04

You can also construct a TemporalData object from l:

l = Values @ {l1, l2, l3, l4};

td = TemporalData[Most /@ l, {Last /@ l},
"MetaInformation" ->
{"ComponentNames" -> {"col 1", "col 2", "col 3", "col 4", "col 5"}}];

ListLinePlot[td, PlotLegends -> td[ "ComponentNames"]]


l = Values @ {l1, l2, l3, l4};

ListLinePlot[Transpose @ Map[Thread @ {Last @ #, Most @ #} &] @ l,
PlotLegends -> Range[Length @ l]]


Do not use numbered variable names because it is not easy to use them. Better, put the data in an array like e.g.:

l0 = {r1, r2, r3, r4, r5, r6};
l=Table[{},4];
l[[1]] =
l0 /. {r1 -> 0.1, r2 -> 0.3, r3 -> 0.1, r4 -> 1.0, r5 -> 0.3, r6 -> 0.1};
l[[2]] =
l0 /. {r1 -> 0.3, r2 -> 0.9, r3 -> 0.5, r4 -> 0.1, r5 -> 0.2, r6 -> 0.2};
l[[3]] =
l0 /. {r1 -> 0.4, r2 -> 0.1, r3 -> 0.2, r4 -> 0.2, r5 -> 0.7, r6 -> 0.3};
l[[4]] =
l0 /. {r1 -> 0.5, r2 -> 0.63, r3 -> 0.4, r4 -> 0.4, r5 -> 0.5, r6 -> 0.4};


Then you can easily assemble the data for a ListPlot:

d = Table[{l[[j, 6]], l[[j, i]]}, {i, 5}, {j, 4}]
ListLinePlot[d]
`

• Thanks, @Daniel Huber. When I run your code, it says: Set: Symbol l in part assignment does not have an immediate value. May 29, 2023 at 7:42
• You are right, I forget to pre-assign l. I fixed it. May 29, 2023 at 7:55