# Plot two variables, one versus the other [closed]

I have a quick question: I'm trying to plot two lists of numbers called "stress" and "strain", where stress depends on strain, so I want that shown in a graph.

I tried using plot, but I understand that only works for functions of one variable.

Is there any other function I could use to do what I need?

Thanks!

ADDED: Suppose stress = {{a},{b},...}, and strain = {{x},{y},...}, where the numbers in stress depend on the numbers in strain. I'm trying to plot that relationship in order to make a polynomial fit, so I thought about ListPlot, but somehow it does not work.

Listplot[{{a,x},{b,y},...}] doesn't seem to do it, because they show an empty plot, so I'm now trying to determine whether there is an error with the lists or if my syntax is wrong...

• may be you need ListPlot – Nasser Jul 13 '18 at 1:59
• i already tried that, but either i don't know the syntax or it's not what i need; i'm trying both LostPlot[{stress,strain}] and ListPlot[{strain,stress}], but nothing's shown in the graph... – SantiMontouliu Jul 13 '18 at 2:05
• There's not enough detail in your question to know exactly what are you trying to do. But, assuming that you have two numerical vectors (one for strain, one for strain), you need to make a list of {{x1,y1},{x2,y2},..{etc}} pairs in order to directly use ListPlot – TumbiSapichu Jul 13 '18 at 2:12
• if you tried it and it does not work, then may be you made an error. You need to have your x,y as in ListPlot[{{x1,y1},{x2,y2}...}}] not as in ListPlot[{{x1,x2,...},{y1,y2,...}}. But hard to help, if you do not show small example of what you did. – Nasser Jul 13 '18 at 2:13
• ListPlot[Transpose[Flatten /@ {Strain, Stress}]] – OkkesDulgerci Jul 13 '18 at 2:57

Note that the format of your data needs to be flattened. As a dummy example, you can do something like:

Strain = Flatten@{{1}, {2}, {3}}
Stress = Flatten@{{10}, {20}, {30}}

data = Table[{Strain[[n]], Stress[[n]]}, {n, 1, Length@Strain}]

ListPlot[data] • That did it, thank you so much for your time! – SantiMontouliu Jul 13 '18 at 2:56
• No problem!! :) – TumbiSapichu Jul 13 '18 at 2:58
• More simply, ListPlot[Transpose[{Strain, Stress}]] or ListPlot[Thread[{Strain, Stress}]] – Bob Hanlon Jul 13 '18 at 3:58

If you data as you show, you could do

strain = {{1}, {2}, {3}};
stress = {{10}, {20}, {30}};
data = Join[strain, stress, 2];
ListPlot[data, Frame -> True, PlotStyle -> Red] 