Closed tomicapretto closed 4 years ago
Commit 1e0876ffec99fcaffbeb75f72d7f48692e521fe0 added two functions flowField2()
and nullclines2()
. The names aren't definite, I just didn't want to delete the original versions because these functions might be modified in the near future.
Now, you can do something like this:
library(magrittr)
func = function(t, state, parameters) {
with(as.list(c(t, state, parameters)), {
dx = a * x ** 2 + b * y ** 2 + c
dy = d * x + e * y
list(c(dx, dy))
})
}
parameters = c(a = 1 , b = 1, c = -4, d = -2, e = 1)
flowField2(
deriv = func,
xlim = c(-3, 3),
ylim = c(-3, 3),
parameters = parameters,
system = "two.dim") %>%
nullclines2(
deriv = func, xlim = c(-3, 3), ylim = c(-3, 3),
parameters = parameters, system = "two.dim", points = 400,
add.legend = TRUE
)
And the output will be
These two functions also allow you to return the data.frames that are consumed by ggplot2. Instead of letting flowField2()
and nullclines2()
generate the plot for you, you take the data.frames and generate your own custom plot via ggplot2 (or via base graphics if you want)
Some questions that arise...
deriv
, parameters
, etc. etc.? geoms_*
and stats_*
instead of this very high level functions?
flowField()
and nullclines()
for example.)Well, those are some thoughts after the commit. The one that concerns me the most is the first, which is something I'd like to address during the next one or two weeks
Great work Tomas! Some thoughts on your points:
deriv
etc.), that could always be the first run function that's then subsequently passed along ? The launch function would be the only one that's not pipeable. Does that make sense?
Opening PR to track changes and discussion about porting current plots to ggplot2.
Do not review changed files because they're changing in the immediate future.