# plotting an array of dataset with ListPlot

Posted 10 years ago
4775 Views
|
3 Replies
|
1 Total Likes
|
 hi, I have a set of datapoints such asval=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 asListPlot[Transpose[{x,data[[1]]}]]and if I want to plot more than one I can doListPlot[{Transpose[{x, data[[1]]}], Transpose[{x, data[[2]]}]}]but how can I plot all of them in one code single line, by considering that val is calculated before in the programIs there a way to do something likeFor[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 solutionAny tutorial added to the answer is more than welcomeThanksSmazzu
3 Replies
Sort By:
Posted 10 years ago
 Hi,  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.I.M.
Posted 10 years ago
 Thanks but indeed it is not the answer to my problem. I need to plot all the data in different curves but in the same graph{{1, 2, 3, 4}, {2, 3, 4, 5}, {3, 4, 5, 6}}with x as common axisAt the end I want to have a graph with val=3 curves, a kind of static way to plot Manipulate[ListPlot[Transpose[{x, data[[i]]}]], {i, 1, val,1}]ThanksSmazzu
Posted 10 years ago
 I thought I found the solution withListPlot[Insert[data,x,1]]but the x value is not the right oneSmazzu