0
$\begingroup$

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...

$\endgroup$

closed as off-topic by AccidentalFourierTransform, Bob Hanlon, m_goldberg, MarcoB, halirutan Jul 13 '18 at 14:02

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Bob Hanlon, m_goldberg, MarcoB, halirutan
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    $\begingroup$ may be you need ListPlot $\endgroup$ – Nasser Jul 13 '18 at 1:59
  • $\begingroup$ 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... $\endgroup$ – SantiMontouliu Jul 13 '18 at 2:05
  • $\begingroup$ 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 $\endgroup$ – PedroSapichu Jul 13 '18 at 2:12
  • $\begingroup$ 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. $\endgroup$ – Nasser Jul 13 '18 at 2:13
  • 3
    $\begingroup$ ListPlot[Transpose[Flatten /@ {Strain, Stress}]] $\endgroup$ – OkkesDulgerci Jul 13 '18 at 2:57
0
$\begingroup$

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]

enter image description here

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

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]

Mathematica graphics

$\endgroup$

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