# Mathematica:Plotting an iterative list on one graph

• Mathematica

## Main Question or Discussion Point

Hi
i want the x -axis to go from 1 to 5, then plot the 2nd element of each pair, (so that they appear in a horizontal row ) for
lis = {{4, 2}, {1, 3}, {2, 5}}

I' ve been playing around with ListPlot and using it with Map[Last,
lis] but not getting what i want

my goal is to repeat this for all 3 time steps
flist = {{{4, 2}, {1, 3}, {2, 5}},
{{1, 2}, {3, 4}, {3, 1}},
{{2, 3}, {0, 5}, {2, 2}}}
so that they appear on seperate rows like the grap shown in the
attachment that i created in excel

Note : im guessing it would be easier to solve if i didn' t have
pairs in the list but the NestList i have created to get these lists \
need to be in this form

#### Attachments

• 27 KB Views: 86

Related MATLAB, Maple, Mathematica, LaTeX News on Phys.org
CompuChip
Homework Helper
I do not have Mathematica here so I cannot test it, but you could try something like
Code:
Table[{i, #}& /@ (Last[Transpose[flist[[i]]]]), {i, 1, Length[flist]}]
I.e. looking at flist[[1]] == {{4, 2}, {1, 3}, {2, 5}}, you transpose to get {{4, 1, 2}, {2, 3, 5}} of which Last[...] gives {2, 3, 5}. Then you map that to a function that takes each of these elements n and produces a list {1, n}, so in the end you will get something like
{{1, 2}, {1, 3}, {1, 5}}.
If you Table that over all other indices, you will get something like
{ {{1, 2}, {1, 3}, {1, 5}}, {{2, 2}, {2, 4}, {2, 1}}, {{3, 3}, {3, 5}, {3, 2}} }
which ListPlot should be able to handle (perhaps after Flatten[..., 1]ing or Partition[Flatten[...], 2]ing it).

Thank you CompuChip

Can I change the y-axis so that it goes (bottom to top) from say 3 to 0 rather that the usual 0 to 3

CompuChip
Homework Helper
You cannot make it run the other way. What you can do is plot -y instead, and use ticks in your options:
Code:
ListPlot[..., AxesOrigin->{0, -3}, Ticks[Automatic, {Range[{-y, y}, {y, 0, 3}]}]
which will put the origin of your axes at y = -3 and place the labels "0", "1", "2" and "3" at y = 0, -1, -2 and -3 respectively.

{ {{1, 2}, {1, 3}, {1, 5}},
{{2, 2}, {2, 4}, {2, 1}},
{{3, 3}, {3, 5}, {3, 2}} }
Is it possibe to colour all the 1st terms of the list e.g. {1,2}, {2,2}, {3,3} blue, {1,3},
{2,4},{3,5} green and {1,5}, {2,1}, {3,2} red using PlotMarker or a simular function

Also, can i find the mean of the last elements of the sublist,
ie. the mean of 2, 3, 5, the mean of 2, 4, 1 and the mean of 3, 5, 2
my attempts haven't been very successful :(

Last edited: