Proves a simple interface to let users interactively design plots in ggformula, lattice, or ggplot2. An option is available to show the code used to create the plot. This can be copied and pasted elsewhere to (into an RMarkdown document, for example) to recreate the plot. Only works in RStudio. Requires the manipulate package.
design_plot(
data,
format,
default = format,
system = system_choices()[1],
show = FALSE,
title = "",
data_text = rlang::expr_deparse(substitute(data)),
...
)
a data frame containing the variables that might be used in the plot.
Note that for maps, the data frame must contain coordinates of the polygons
comprising the map and a variable for determining which coordinates are part
of the same region. See sp2df()
for one way to create such
a data frame. Typically merge()
will be used to combine the map
data with some auxiliary data to be displayed as fill color on the map, although
this is not necessary if all one wants is a map.
a synonym for default
.
default type of plot to create; one of
"scatter"
,
"jitter"
,
"boxplot"
,
"violin"
,
"sina"
,
"histogram"
,
"density"
,
"density (contours)"
,
"density (filled)"
,
"frequency polygon"
,
"xyplot"
,
or
"map"
. Unique prefixes suffice.
which graphics system to use (initially) for plotting (ggplot2 or lattice). A check box will allow on the fly change of plotting system.
a logical, if TRUE
, the code will be displayed each time the plot is
changed.
a title for the plot
A text string describing the data. It must be possible to recover the data
from this string using eval()
. Typically users will not need to
modify this from the default value.
additional arguments
Nothing. Used for side effects.
Currently maps are only supported in ggplot2 and not in lattice.
Due to an unresolved issue with RStudio, the first time this function is called, and additional plot is created to correctily initialize the mainipulate frameowrk.