Open dtkaplan opened 5 years ago
graphFun()
and plotFun()
are very similarly named and the names don't do much to specify how they differ. So I'm wondering...
plotFun()
to work with gg rather than lattice plots? Or add a system
argument like we have done with other functions.mosaicCalc
-- it isn't really calculus, but is perhaps more likely to be used in a calculus context.gf_fun()
and gf_fun2d()
in ggformula? It might be better to work from those rather than from plotModel()
. plotModel()
reflects where we were 5 years ago more than where I think we are going.The threshold for adding to the mosaic suite should be high. New things should have a clear use case and play well with the parts of the suite we are most committed too. I'm not sure this crosses that threshold for me. But perhaps something more related to gf_fun()
and gf_fun2d()
and housed in ggformula would be better.
library(ggformula); theme_set(theme_bw()); example(gf_fun2d)
#> gf_fn2> gf_function_2d(fun = function(x, y) sin(2 * x * y), xlim = c(-pi, pi), ylim = c(-pi, pi)) %>%
#> gf_fn2+ gf_refine(scale_fill_viridis_c())
#>
#> gf_fn2> gf_function_2d(fun = function(x, y) x + y, contour = FALSE)
#>
#> gf_fn2> gf_function_tile(fun = function(x, y) x * y) %>%
#> gf_fn2+ gf_function_contour(fun = function(x, y) x * y, color = "white") %>%
#> gf_fn2+ gf_refine(scale_fill_viridis_c())
#>
#> gf_fn2> gf_fun_tile(x * y ~ x + y, xlim = c(-3, 3), ylim = c(-2, 2)) %>%
#> gf_fn2+ gf_fun_contour(x * y ~ x + y, color = "white") %>%
#> gf_fn2+ gf_refine(scale_fill_viridis_c()) %>%
#> gf_fn2+ gf_labs(fill = "product")
Created on 2019-08-23 by the reprex package (v0.3.0)
The graphFun()
is built on top of gf_fun()
and gf_fun2d()
. But I want a separate function because I want to be able to specify limits other than as xlim =
and ylim =
. Also, for the tile plots, I want the alpha set by default to something light, e.g. 0.5.
I thought about whether to create a new name, graphFun
, or modify the existing function plotFun
to work with ggplot2. The problem is to avoid breaking existing stuff, plotFun
has an argument add=
for piling up layers. That's utterly different from the piping scheme used in ggplot2. So existing code (with add=TRUE
) would break.
Since graphFun()
doesn't follow ggplot2/ggformula conventions such as %>% gf_lims(x = c(0,10))
or xlims = c(0,10)
, I thought that graphFun
shouldn't be in ggformula
. Putting it in mosaic
would be fine, but for the present it's easier for me to work with the much smaller mosaicCalc
package.
Changing the default alpha level would be easily done in ggformula. (We do that for histograms already.)
gf_histogram() uses
* a formula with shape ~x or y ~ x.
* geom: bar
* stat: bin
* position: stack
* key attributes: bins = 25, binwidth, alpha = 0.5, color, fill, group, linetype, size
But I'm not sure I'm keen to have another interface that "doesn't follow ggformula conventions" just to have a different way to set limits. And I have some concerns about confusion between plotFun()
and graphFun()
. (These concerns are somewhat reduced by the fact that I'm less interested in plotFun()
now that we have ggformula.)
I'll have to take a closer look and mull this over some more.
@nicholasjhorton: any thoughts?
@dtkaplan: Any new thoughts here? Or should this just be closed?
In the branch graphFun, I've added a function graphFun() which:
t^2 ~ t
, acceptable limit arguments are t = c(0,10), tlim = c(0,10), or xlim = c(0,10)