# Make a scatter plot from two columns of matrix

I have imported my text-type data as a matrix. I want to make a scatter plot (ListPlot) using one column as x-axis and other columns as y-axis.

Is there a function F which can make a scatter plot in the following form?

F[matrix[[All, 1]], {matrix[[All,2],...,matrix[[All,n]]]]


E.g.:

test = {{1, 2, 3}, {2, 4, 6}, {3, 5, 9, 11}};

ListPlot[Map[Thread[List[#[], #[[2 ;;]]]] &, test], PlotStyle -> PointSize[.02]] • Dear, I really cannot understand your method.Fist, my data is a matrix why still using List to form a list. Sceond, what does the function Thread and Map here. I have searched these functions in reference center. I could understand these functions respectively. But, when these functions combined, it really confused me. – wikichung May 19 '14 at 12:20
• @wikichung: Arrays are just specializations of lists (they are lists, in other words). The Thread piece is a short way of making a list of lists with some constant element, Map takes that over all of the data. Let me know if that's clear... – ciao May 20 '14 at 2:27
• it works and can plot many lines – wikichung May 23 '14 at 0:54
• @wikichung: Glad to hear. Consider accepting an answer (little check-mark) that best fits your question. – ciao May 23 '14 at 1:03
• it works and can plot many lines.ListPlot[Map[Thread[List[#[], {#[[i]],#[[j]]}]] &, test], PlotStyle -> PointSize[.02]] – wikichung May 23 '14 at 1:08

The new-in-9 TemporalData can be convenient for the current task:

data = RandomReal[10, {30, 5}];
td = TemporalData[Rest@Transpose@data, {First@Transpose@data}];
ListPlot[td, Joined -> True, PlotMarkers -> Automatic, ImageSize -> 400] • I tried your method, but it did not work. :( – wikichung May 19 '14 at 12:07
• @wikichung, what are the Dimensions of your matrix (what do you get when you evaluate Dimensions[matrix]?) Does the method work if you remove the Transpose@ pieces in the code in this post? – kglr May 19 '14 at 13:08
• my data are collected by a collector, so it is a 8000x9 matrix. The first column is the time, and others column is my signals. – wikichung May 20 '14 at 1:39

Try this.

This approach correct if Length[xAxisdData]==Length[yAxesdData[[i]]]

xAxisdData={1,2,3,4};
yAxesdData={{1,2,3,4},{1,4,9,16}};
dataToPlot=Transpose[{xAxisdData,#}]&/@yAxesdData;
ListPlot[dataToPlot,PlotStyle->PointSize[.02]] list = Table[5 i + j, {i, 10}, {j, 10}];


if so, you can convert the table into the matrixform with:

MatrixForm[list];


and plot every Line as usual:

ListPlot[{list[], list[], list[]}] If you like to plot Line 1 vs Line 6 you can use:

ListPlot[{list[], list[]} // Transpose] • Dear, my data are collected by a collector, so it is a 8000x9 matrix. The first column is the time, and others column is my signals. It seems that my matrix does not fit your supposed form. – wikichung May 20 '14 at 1:38
• My data are collected by a collector, so it is a 8000x9 matrix. The first column is the time, and others column is my signals. it seems that my matrix does not fit your supposed form. – wikichung May 20 '14 at 1:42

For this, Part (shorthand [[]]) is your friend. Using

data = RandomReal[{0, 10}, {20, 5}];


as the data set, you can extract multiple columns as follows:

data[[All, {x, y}]]


where x is the x-column and y is the y-column. Note, x can equal y and even be larger than y. Their values are only constrained by the number of columns, with one exception: negative indices are treated as starting from the end of the list, not the beginning like positive indices. To get multiple data sets, you have to be a little creative,

data[[All, {1, #}]]& /@ Range[2, Length@data[]]