0
$\begingroup$

I am trying to create plots starting from values that I have in an Excel spreadsheet. The values of interest are contained in three rows, which I will call 1, 2, and 3 for the sake of this discourse. The thing is, even if I get the data into Mathematica, it treats the data as if it were a list of y values.

Is there a command to specify that the values in row 1 are values of the independent variable x? Is there a way to plot the values in rows 2 and 3 against row 1 in the same plot?

$\endgroup$
1
$\begingroup$

I'll guess your data looks like

data = {{1, 2, 3, 4}, {10, 19, 28, 41}, {11, 21, 30, 39}};

where the first bracket is the first row, and the other two brackets are the other rows. You could then get the plot you're looking for as

ListPlot[Transpose@data[[{1, #}]] & /@ {2, 3}]

where you can fill in whichever rows you're interested in for the {2,3}.

$\endgroup$
0
$\begingroup$

Assuming you are able to get the data into Mathematica and that I understand your question correctly, you can parse the dataset directly in any discrete plotting function.

Making up some data:

x = Subdivide[0, 1, 99];
y = RandomReal[{0, 1}, 100];
z = RandomReal[{0, 1}, 100];

Or, if you import the data as a single set:

data = {x, y, z};

You can plot using either

ListLinePlot[MapThread[Flatten@*List, {x, #}] & /@ {y, z}]

or

ListLinePlot[MapThread[Flatten@*List, {data[[1]], #}] & /@ data[[2 ;;]]]

to obtain the plot

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.