val=3; (*this value is calculated before in the program, so it not known a priori*)
x={0,1,2,3};
data = Table[0, {val}];
For[i = 1, i < val + 1, i++,
data[[i]] = x+i];
Now I can plot each of these data with ListPlot as
but how can I plot all of them in one code single line, by considering that val is calculated before in the program
Is there a way to do something like
For[i = 1, i < val + 1, i++, ListPlot[Transpose[{x,data[*]}]]…]?
I was thinking about the use of Show and overlap the graphs, but probably there is an easier solution
Any tutorial added to the answer is more than welcome
Thanks
Smazzu*
x = {0, 1, 2, 3};
(* do not use For or Do unless it's completely unavoidable *)
data = Table[x[[i]] + i, {i, 1, Length[x]}];
(* note now x and data have the same length *)
Length[x]
Length[data]
(* you can transpose only lists of an equal length *)
Transpose[{x, data}]
(* it's ready to plot *)
ListPlot[%]
(* use Show[] for different types of graphics *)
Not sure about a complete tutorial, but F1 can help, at least simple examples can be found there.
Also try to search the web for solutions, many problems are already solved.