1
$\begingroup$

I have a list of points

Rabbits={{0,20},{0.01,20.0024},{0.02,20.0071}...}

Foxes={{0,40},{0.01,39.76},{0.02,39.5214}...}

I want to create a phase plane with these points. I've tried using ParametricPlot,

ParametricPlot[{Rabbits, Foxes}, {t, 0, 100}]

But Mathematica keep running. What am I doing wrong?

$\endgroup$
1
  • $\begingroup$ You should share your complete data. $\endgroup$
    – zhk
    Feb 19, 2017 at 16:43

2 Answers 2

1
$\begingroup$

ListStreamPlot

Are you looking for something like this?

data = Table[{{x, y}, {y, x - x^2}}, {x, -1.5, 1.5, 0.2}, {y, -2, 2, 0.2}];
ListStreamPlot[data]

Edit

ParametricPlot

Since you haven't provided a complete data. So, I will generate my own while taking data from a predator-prey model, to make my response more relevant to the question.

sol = With[{r = 0.5}, NDSolve[{U'[t] == r*(U[t] - U[t]*V[t]), 
     V'[t] == 1/r*(U[t]*V[t] - V[t]), U[0] == 1.1, V[0] == 1}, {U, 
     V}, {t, 0, 20}]];

You can think of U to be rabbits density and V foxes density.

rabbitsdata = Table[Flatten@Evaluate[{t, U[t]} /. sol], {t, 0, 20, 0.1}];
foxesdata = Table[Flatten@Evaluate[{t, V[t]} /. sol], {t, 0, 20, 0.1}];

The structure of the above data is like the one you provided, i.e, {{time, Rabbitdensity},....}.

Now, I will interpolate the above data to generate two interpolating functions,

{U, V} = ListInterpolation[#, {{0, 20}}] & /@ {rabbitsdata[[All, 2]], foxesdata[[All, 2]]};

Finally, plotting the phase-portrait using ParametricPlot,

ParametricPlot[{U[t], V[t]}, {t, 0, 20}, Frame -> True]

enter image description here

$\endgroup$
2
  • $\begingroup$ Yes, this is perfect!! $\endgroup$ Feb 19, 2017 at 16:48
  • $\begingroup$ @Deborah_Watson For more details about this, you should search ListStreamPlot. $\endgroup$
    – zhk
    Feb 19, 2017 at 16:49
0
$\begingroup$

Parametric plot is used to plot parametric functions. In your case you should use ListPlot instead.

For this first you need list of two tuples like {{20,40},{20.0024,39.76}....}. This can be achieved as follows:

Transpose[{Transpose[Rabbits[[2, All]]], Transpose[Foxes[[2, All]]]}] 

Once you are done, you can use ListPlot to get desired output:

ListPlot[Transpose[{Transpose[Rabbits[[2, All]]], Transpose[Foxes[[2, All]]]}], PlotRange->All] 
$\endgroup$
1
  • $\begingroup$ This is just the thing I wanted, thank you soo much. I can't believe how simple that was!!! $\endgroup$ Feb 20, 2017 at 20:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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