ProjectMOSAIC / ggformula

Provides a formula interface to 'ggplot2' graphics.
Other
38 stars 9 forks source link

Proposed replacement for gf_fun() #59

Open dtkaplan opened 6 years ago

dtkaplan commented 6 years ago

In updating mosaicCalc I've written a function plot_f1() as a prototype for bringing ggformula graphics into the calculus vignette.

ggformula already contains gf_fun(), which is good for plotting a function of one variable. What's different about plot_f1() is that it will plot functions of several variables. The formula that defines the function is used to specify which is the x-axis variable. The conditional part of the formula (if any) specifies the variables to be used for faceting. Additional arguments, e.g. color = ~ a, can be used for variables that don't appear to the right of the tilde.

An example (that's way too elaborate):

plot_f1(A * sin(2 * pi * t/P) ~ t | P, 
            t = c(0,100), P = 10*(1:3),  A = 1:3, color = ~ A)

image

I've rewritten (and expanded) the examples given in the docs for gf_fun(). This indicates that plot_f1() could be used as a replacement for gf_fun(). To me it makes much more sense to add it to ggformula than to have an independent function in mosaicCalc.

You can see plot_f1() in action by installing mosaicCalc from GitHub.

If this seems like a good line to persue, I'll extend it to handle functions of the form sin(a * x) ~ x +a in which case it will draw a contour plot of the LHS in the space defined by the RHS.

rpruim commented 6 years ago

This dropped off my radar and I haven't played with it yet.

A few questions:

I'll have to look at it more carefully later, but if it only extends gf_fun(), there is probably no downside to replacing gf_fun() in ggformula.

rpruim commented 6 years ago

@dtkaplan, any more work on this? Should we try replacing gf_fun()?

dtkaplan commented 6 years ago

I haven't followed up on this. Since the mosaicCalc package isn't widely used, let's defer this issue until when I start working to update the documentation for mosaicCalc.