How to generate graph graph and equilibrium graph?

I used Python in the past, but slowly moved to R. I'm currently trying to create a quiver / direction field graph and an equilibrium graph. I was able to do this in Python, the links to examples below, but hardly reflected it in R. In Python, I was able to use packages like numpy, matplotlib.pyplot, mpl_toolkits.mplot3d and scipy.integrate. I'm currently trying to use deSolve, pracma and matlab. Are there other packages that I should use, or functions in these packages, and I can’t get them to work? Below is an example of the code from the paper that I came across. Any help would be greatly appreciated.

#Solve the system dy/dt = f(y, t) and model equations
Example <- function(t, state, parameters) {
  with(as.list(c(state, parameters)), {

    dK <-  a * K - b * H - c * F - d * H * F
    dH <-  b * H - a * K + c * F + e * F
    dF <-  f + c * F - a * K + b * H + h * K
    list(c(dK, dH, dF))
  })
}

#Parameters and Initial Conditions
parameters <- c(a = 0.02, 
                b = 0.01, 
                c = 0.04, 
                d = 0.06, 
                e = 0.08, 
                f = 0.2,  
                h = 0.04)
state      <- c(K = 0.7, 
                H = 0.6, 
                F = 0.3) 
times      <- seq(0, 100, by = 0.01) 

out <- ode(y = state, times = times, func = Example, parms = parameters)

plot(out)

Here are the links to the graphs that I'm trying to reflect as much as possible:

Equilibrium graph

enter image description here

Quiver / Direction Field Graph

enter image description here

+4
1

, - , . 3D- . X11, psuedo-3d sapce, . rgl.snapshot . :

require(rgl)
 open3d()
#------
NSOpenGL 
      11 
> lines3d( x=out[, 2]/diff(range(out[, 2])),  y=out[, 3]/diff(range(out[, 3])), z=out[, 4]/diff(range(out[, 4])))
> axes3d()
> range(out[, 2])
[1] -599.9068  309.3532
> range(out[, 1])
[1]   0 100
> range(out[, 4])
[1] -18.02914  23.64377
> range(out[, 3])
[1]   0.6000 165.0494
> rgl.snapshot("equil.png")

enter image description here

scatterplot3d:

require(scatterplot3d); scatterplot3d( out[, 2],  out[, 3], out[, 4])

enter image description here

+1

Source: https://habr.com/ru/post/1599608/


All Articles