ProjectMOSAIC / mosaicCalc

Calculus in R
12 stars 4 forks source link

Order of layers shouldn't matter #16

Closed dtkaplan closed 1 year ago

dtkaplan commented 1 year ago

This doesn't work when the vectorfield_plot() is put first in the pipe. (Also, the bounds shouldn't be needed in any layer but the first, but that's the subject of Issue 11.

dt_rabbit <- function(r, f, alpha=2/3, beta=4/3) {
  alpha*r - beta*r*f
}
dt_fox <- function(r, f, delta=1, gamma=1) {
  -delta*f + gamma*r*f
}
contour_plot(dt_rabbit(r,f) ~ r & f, bounds(r=0.2:2, f=0.05:1), 
             contours_at = 0, contour_color = "red",
             labels=FALSE) %>%
  contour_plot(dt_fox(r,f) ~ r & f, bounds(r=0.2:2, f=0.05:1),
             contours_at = 0, contour_color = "blue",
             labels=FALSE) %>%
  vectorfield_plot(r ~ dt_rabbit(r,f),
                   f ~ dt_fox(r,f), bounds(r=0.2:2, f=0.05:1),
                   transform=function(x) x^0.3)