plot_scatter()
creates a pre-themed scatterplot on two variables, optionally grouped by a
third categorical variable.
Arguments
- data
A data frame.
- formula
Variables to build the plot on. Should be entered in formula notation,
var1~var2
.- fill
The fill of the plot. Valid options are a character color (for standard scatterplots) or a variable given in formula notation (
~var
), used to create a grouped scatterplot.- title
An override for the title of the plot. A sensible default is provided.
- subtitle
A switch for hiding the default subtitle. One of "show" or "hide".
- legend_title
The title of the lengend. Ignored in non-grouped plots. Default is the variable name.
- axis_lines
Should major axis lines appear on the plot? Valid options are "none" or "both. Defaults to "none".
- ls_line
Should a least squares line (or lines) appear on the plot? Defaults to "hide".
- ...
Extra title arguments passed on to
ggformula::gf_labs()
(which feeds toggplot2::ggplot()
).
Examples
plot_scatter(mtcars, wt~drat)
#> Note: NAs always removed (in pairs) for scatterplots.
#> This message is displayed once every 8 hours.
plot_scatter(mtcars, wt~drat, fill = "red")
plot_scatter(mtcars, wt~drat, axis_lines = "both")
plot_scatter(mtcars, wt~drat, ls_line = "show")
plot_scatter(mtcars, wt~drat, fill = ~cyl)
plot_scatter(mtcars, wt~drat, fill = ~cyl, ls_line = "show")
plot_scatter(mtcars, wt~drat, fill = ~cyl, legend_title = "Cylinders")