tinyplot_add {tinyplot} | R Documentation |
Add new elements to the current tinyplot
Description
This convenience function grabs the preceding tinyplot
call and updates it
with any new arguments that have been explicitly provided by the user. It
then injects add=TRUE
and evaluates the updated call, thereby drawing a new
layer on top of the existing plot. plt_add()
is a shorthand alias for
tinyplot_add()
.
Usage
tinyplot_add(...)
plt_add(...)
Arguments
... |
All named arguments override arguments from the previous calls. Arguments not supplied to tinyplot_add remain unchanged from the previous call. |
Value
No return value, called for side effect of producing a plot.
Limitations
-
tinyplot_add()
works reliably only when adding to a plot originally created using thetinyplot.formula
method with a validdata
argument. We cannot guarantee correct behavior if the original plot was created with the atomictinyplot.default
method, due to potential environment mismatches. (An exception is when the original plot arguments—x
,y
, etc.—are located in the global environment.) Automatic legends for the added elements will be turned off.
Examples
tinyplot(Sepal.Width ~ Sepal.Length | Species,
facet = ~Species,
data = iris)
tinyplot_add(type = "lm") ## or : plt_add(type = "lm")
## Note: the previous function is equivalent to (but much more convenient
## than) re-writing the full call with the new type and `add=TRUE`:
# tinyplot(Sepal.Width ~ Sepal.Length | Species,
# facet = ~Species,
# data = iris,
# type = "lm",
# add = TRUE)