I have imported a csv file into a list with this stmt:
data1 = Take[Import["D:\\_reports\\optim_5_60_b_2.csv", "CSV"], 5]
Which gives:
{{178, 8, 9, 1}, {152, 2, 8, 1}, {378, 8, 9, 2},
{343, 3, 7.5`, 2}, {143, 3, 7.5`, 1}}
I would like to create a plot where the x-axis is based on the first field:
178,152,378,343,143,373,743,352
And the plot creates a line for each subsequent field, so the 2nd field is:
8,2,8,3,3,3,3,2
This would be the first line on the y-axis, the other y-axis values would be plotted in the same manner. I would like the first y-plot to be plotted in red, and the second in blue, and the third in green.
And an alternative version:
data = {{178, 8, 9, 1}, {152, 2, 8, 1}, {378, 8, 9, 2},
{343, 3, 7.5, 2}, {143, 3, 7.5, 1}};
x = data[[All, 1]];
ListLinePlot[
Transpose[
Sort[MapThread[Function[xpt, {xpt, #} & /@ #2][#1] &,
{x, Rest /@ data}]]], PlotStyle -> {Red, Blue, Green},
PlotMarkers -> {Automatic, 10}, AxesOrigin -> {Min@x, Automatic}]
Similarly, but easier to read:
ListLinePlot[
Transpose[
Sort[Table[Map[{data[[i, 1]], #} &, Rest[data[[i]]]],
{i, Length[data]}]]], PlotStyle -> {Red, Blue, Green},
PlotMarkers -> {Automatic, 10}, AxesOrigin -> {Min@x, Automatic}]
You can do :
data1 = {{178, 8, 9, 1}, {152, 2, 8, 1}, {378, 8, 9, 2}, {343, 3, 7.5,
2}, {143, 3, 7.5, 1}};
tobeplotted = With[{LocalX = data1[[All, 1]]},
Transpose[{LocalX, #}] & /@ Transpose[data1[[All, 2 ;;]]]]
ListPlot[tobeplotted, PlotStyle -> {Red, Blue, Green}, PlotMarkers -> {Automatic, 10}]
I propose this:
dat = {{178, 8, 9, 1}, {152, 2, 8, 1}, {378, 8, 9, 2},
{343, 3, 7.5`, 2}, {143, 3, 7.5`, 1}};
ListLinePlot[
Thread[Thread@{#, {##2}} & @@@ Sort@dat],
PlotStyle -> {Red, Blue, Green}
]