point_plot()
makes it easy to construct an informative basic graph of a
data frame. "Making it easy" means that the user only needs to specify
two things: 1) the data frame to be used and 2) a tilde expression with the response variable on the left and up to
three explanatory variables on the right. The response variable is mapped to
the vertical axis while the first explanatory variable defines
the horizontal axis. The second explanatory variable (if any) maps to color,
the third (if any) defines facets. Quantitative variables used for color or faceting
are cut into categorical variables, so color and facets will always be discrete.
point_plot(
D,
tilde,
...,
seed = 101,
annot = c("none", "violin", "model", "bw"),
jitter = c("default", "none", "all", "x", "y"),
interval = c("confidence", "none", "prediction"),
point_ink = 0.5,
model_ink = 0.4,
palette = LETTERS[1:8],
bw = NULL,
level = 0.95,
nx = 50,
model_family = NULL
)
A ggplot graphics object
a data frame
tilde expression specifying y ~ x
or y ~ x + color
(optional) random seed for jittering
Statistical annotation (one of "none", "violin", "model", "bw")
Options for turning on jitter: one of "default"
, "both"
, "none"
, "x"
, "y"
. By default,
By default, categorical variables are jittered.
the type of interval: default "confidence"
. Others: "none"
or "prediction"
Opacity of ink for the data points
Opacity of ink for the model annotation
Depending on taste and visual capabilities, some people might
prefer to alter the color scheme. There are 8 palettes available: "A"
through "H"
.
bandwidth for violin plot
confidence level to use (0.95)
Number of places to evaluate any x-axis quantitative vars. Default 50. Use higher if graph isn't smooth enough.
Override the default model type. See model_train()
Graphical options for the data points, labels, e.g. size
When an x- or y- variables is categorical, jittering is automatically applied.
Using annot = "model"
will annotate the data with the graph of a
model --- shown as confidence intervals/bands --- corresponding to
the tilde expression. annot = "violin"
will annotate with a violin plot.
If you want to use the same explanatory variable for color and faceting
(this might have pedagogical purposes) merely repeat the name of the color variable
in the faceting position, e.g. mpg ~ hp + cyl + cyl
.
add_plot_labels
to add labels to the plot (without needing the ggplot2 + pipe)
mosaicData::Galton |> point_plot(height ~ mother + sex + father, annot="model", model_ink=1)
mtcars |> point_plot(mpg ~ wt + cyl)
mtcars |> point_plot(mpg ~ wt + cyl + hp, annot="model")
Run the code above in your browser using DataLab