ggformula functions provide a formula interface to ggplot2
layer
functions.
For plots with just one layer, the formula interface
is more compact and is consistent with modeling and mosaic notation.
The functions generate a ggplot
command string which can be displayed by
setting verbose = TRUE
as an argument.
gf_curve(object = NULL, gformula = NULL, data = NULL, geom = type,
verbose = FALSE, add = inherits(object, c("gg", "ggplot")), ...,
position = NULL, show.help = NULL)
When chaining, this holds an object produced in the earlier portions of the chain. Most users can safely ignore this argument. See details and examples.
A formula with shape y + yend ~ x + xend
.
Faceting can be acheived by including |
in the formula.
A data frame with the variables to be plotted.
A way to specify ggplot geoms that are not aliased to gf functions.
If TRUE
print the ggplot2 command in the console.
If TRUE
then construct just the layer with no frame. The result
can be added to an existing frame.
Additional arguments. Typically these are
(a) ggplot2 aesthetics to be set with attribute = value
,
(b) ggplot2 aesthetics to be mapped with attribute = ~expression
, or
(c) attributes of the layer as a whole, which are set with attribute = value
.
Available attributes include
alpha
, color
, group
, linetype
, size
, curvature
, angle
, ncp
, arrow
, lineend
Position adjustment, either as a string, or the result of a call to a position adjustment function.
If TRUE
, display some minimal help.
a gg object
Positional aesthetics are typically specified using a formula (see the gformula
argument).
Additional formula terms of the form + attribute::value
map attribute
to value
.
Additional terms of the form + attribute:value
will map attribute
to value
if value
is the name of a variable in data
, else
attribute
will be set to the constant value
. Alternatively (and preferably)
attributes can be set can be set using arguments of the form attribute = value
or
mapped using arguments of the form attribute = ~ expression
.
In formulas of the form A | B
, B
will be used to form facets using
facet_wrap()
or facet_grid()
.
This provides an alternative to
gf_facet_wrap()
and
gf_facet_grid()
that is terser and may feel more familiar to users
of lattice.
Evaluation of the ggplot2 code occurs in the environment of gformula
.
This will typically do the right thing when formulas are created on the fly, but might not
be the right thing if formulas created in one environment are used to create plots
in another.
# NOT RUN {
D <- data.frame(x1 = 2.62, x2 = 3.57, y1 = 21.0, y2 = 15.0)
gf_point(mpg ~ wt, data = mtcars) %>%
gf_curve(y1 + y2 ~ x1 + x2, data = D, color = "navy") %>%
gf_segment(y1 + y2 ~ x1 + x2, data = D, color = "red")
# }
Run the code above in your browser using DataLab