diff --git a/R/tinyplot.R b/R/tinyplot.R index 261c6888..4f9ad617 100644 --- a/R/tinyplot.R +++ b/R/tinyplot.R @@ -90,21 +90,35 @@ #' - `"S"` Stair steps #' - `"h"` Histogram-like vertical lines #' - `"n"` Empty plot over the extent of the data -#' - `tinyplot` types: -#' - `"rect"`, `"segments"`, or `"polygon"`: Equivalent to base `R` -#' - `"density"`: Kernel density plot -#' - `"jitter"` or `type_jitter()`: Jittered points -#' - `"polypath"` or `type_polypath()` -#' - `"boxplot"` or `type_boxplot()` -#' - `"histogram"` or `type_histogram()` -#' - `"pointrange"` or `"errorbar"`: segment intervals -#' - `"ribbon"` or `"area"` for polygon intervals (where area plots -#' are a special case of ribbon plots with `ymin` set to 0 and `ymax` -#' set to `y`; see below). -#' - `"lm"` or `type_lm()`: Linear model fit -#' - `"glm"` or `type_glm()`: Generalized linear model fit -#' - `"loess"` or `type_loess()`: Local regression fit -#' - `"spline"` or `type_spline()`: Cubic spline fit +#' - `tinyplot`-specific types. These fall into several categories: +#' - Shapes: +#' - `"area"` / [`type_area()`]: Plots the area under the curve from `y` = 0 to `y` = f(`x`). +#' - `"errorbar"` / [`type_errorbar()`]: Adds error bars to points; requires `ymin` and `ymax`. +#' - `"pointrange"` / [`type_pointrange()`]: Combines points with error bars. +#' - `"polygon"` / [`type_polygon()`]: Draws polygons. +#' - `"polypath"` / [`type_polypath()`]: Draws a path whose vertices are given in `x` and `y`. +#' - `"rect"` / [`type_rect()`]: Draws rectangles; requires `xmin`, `xmax`, `ymin`, and `ymax`. +#' - `"ribbon"` / [`type_ribbon()`]: Creates a filled area between `ymin` and `ymax`. +#' - `"segments"` / [`type_segments()`]: Draws line segments between pairs of points. +#' - Visualizations: +#' - `"boxplot"` / [`type_boxplot()`]: Creates a box-and-whisker plot. +#' - `"density"`: Plots the density estimate of a variable. +#' - `"histogram"` / [`type_histogram()`]: Creates a histogram of a single variable. +#' - `"jitter"` / [`type_jitter()`]: Jittered points. +#' - `"qq"` / [`type_qq()`]: Creates a quantile-quantile plot. +#' - `"ridge"` / [`type_ridge()`]: Creates a ridgeline (aka joy) plot. +#' - `"spineplot"` / [`type_spineplot()`]: Creates a spineplot or spinogram. +#' - Models: +#' - `"loess"` / [`type_loess()`]: Local regression curve. +#' - `"lm"` / [`type_lm()`]: Linear regression line. +#' - `"glm"` / [`type_glm()`]: Generalized linear model fit. +#' - `"spline"` / [`type_spline()`]: Cubic (or Hermite) spline interpolation. +#' - Functions: +#' - [`type_abline()`]: line(s) with intercept and slope. +#' - [`type_hline()`]: horizontal line(s). +#' - [`type_vline()`]: vertical line(s). +#' - [`type_function()`]: arbitrary function. +#' - [`type_summary()`]: summarize `y` by unique values of `x`. #' @param xmin,xmax,ymin,ymax minimum and maximum coordinates of relevant area #' or interval plot types. Only used when the `type` argument is one of #' `"rect"` or `"segments"` (where all four min-max coordinates are required), diff --git a/man/tinyplot.Rd b/man/tinyplot.Rd index 80d32754..666868e2 100644 --- a/man/tinyplot.Rd +++ b/man/tinyplot.Rd @@ -212,22 +212,44 @@ type of plot desired. \item \code{"h"} Histogram-like vertical lines \item \code{"n"} Empty plot over the extent of the data } -\item \code{tinyplot} types: +\item \code{tinyplot}-specific types. These fall into several categories: \itemize{ -\item \code{"rect"}, \code{"segments"}, or \code{"polygon"}: Equivalent to base \code{R} -\item \code{"density"}: Kernel density plot -\item \code{"jitter"} or \code{type_jitter()}: Jittered points -\item \code{"polypath"} or \code{type_polypath()} -\item \code{"boxplot"} or \code{type_boxplot()} -\item \code{"histogram"} or \code{type_histogram()} -\item \code{"pointrange"} or \code{"errorbar"}: segment intervals -\item \code{"ribbon"} or \code{"area"} for polygon intervals (where area plots -are a special case of ribbon plots with \code{ymin} set to 0 and \code{ymax} -set to \code{y}; see below). -\item \code{"lm"} or \code{type_lm()}: Linear model fit -\item \code{"glm"} or \code{type_glm()}: Generalized linear model fit -\item \code{"loess"} or \code{type_loess()}: Local regression fit -\item \code{"spline"} or \code{type_spline()}: Cubic spline fit +\item Shapes: +\itemize{ +\item \code{"area"} / \code{\link[=type_area]{type_area()}}: Plots the area under the curve from \code{y} = 0 to \code{y} = f(\code{x}). +\item \code{"errorbar"} / \code{\link[=type_errorbar]{type_errorbar()}}: Adds error bars to points; requires \code{ymin} and \code{ymax}. +\item \code{"pointrange"} / \code{\link[=type_pointrange]{type_pointrange()}}: Combines points with error bars. +\item \code{"polygon"} / \code{\link[=type_polygon]{type_polygon()}}: Draws polygons. +\item \code{"polypath"} / \code{\link[=type_polypath]{type_polypath()}}: Draws a path whose vertices are given in \code{x} and \code{y}. +\item \code{"rect"} / \code{\link[=type_rect]{type_rect()}}: Draws rectangles; requires \code{xmin}, \code{xmax}, \code{ymin}, and \code{ymax}. +\item \code{"ribbon"} / \code{\link[=type_ribbon]{type_ribbon()}}: Creates a filled area between \code{ymin} and \code{ymax}. +\item \code{"segments"} / \code{\link[=type_segments]{type_segments()}}: Draws line segments between pairs of points. +} +\item Visualizations: +\itemize{ +\item \code{"boxplot"} / \code{\link[=type_boxplot]{type_boxplot()}}: Creates a box-and-whisker plot. +\item \code{"density"}: Plots the density estimate of a variable. +\item \code{"histogram"} / \code{\link[=type_histogram]{type_histogram()}}: Creates a histogram of a single variable. +\item \code{"jitter"} / \code{\link[=type_jitter]{type_jitter()}}: Jittered points. +\item \code{"qq"} / \code{\link[=type_qq]{type_qq()}}: Creates a quantile-quantile plot. +\item \code{"ridge"} / \code{\link[=type_ridge]{type_ridge()}}: Creates a ridgeline (aka joy) plot. +\item \code{"spineplot"} / \code{\link[=type_spineplot]{type_spineplot()}}: Creates a spineplot or spinogram. +} +\item Models: +\itemize{ +\item \code{"loess"} / \code{\link[=type_loess]{type_loess()}}: Local regression curve. +\item \code{"lm"} / \code{\link[=type_lm]{type_lm()}}: Linear regression line. +\item \code{"glm"} / \code{\link[=type_glm]{type_glm()}}: Generalized linear model fit. +\item \code{"spline"} / \code{\link[=type_spline]{type_spline()}}: Cubic (or Hermite) spline interpolation. +} +\item Functions: +\itemize{ +\item \code{\link[=type_abline]{type_abline()}}: line(s) with intercept and slope. +\item \code{\link[=type_hline]{type_hline()}}: horizontal line(s). +\item \code{\link[=type_vline]{type_vline()}}: vertical line(s). +\item \code{\link[=type_function]{type_function()}}: arbitrary function. +\item \code{\link[=type_summary]{type_summary()}}: summarize \code{y} by unique values of \code{x}. +} } }} diff --git a/vignettes/types.qmd b/vignettes/types.qmd index 300e3521..932c5f28 100644 --- a/vignettes/types.qmd +++ b/vignettes/types.qmd @@ -56,14 +56,14 @@ a convenience string (with default behaviour) or a companion `type_*()` function Shapes: -- `area` / `type_area()`: Plots the area under the curve from `y` = 0 to `y` = f(`x`). +- `"area"` / `type_area()`: Plots the area under the curve from `y` = 0 to `y` = f(`x`). - `"errorbar"` / `type_errorbar()`: Adds error bars to points; requires `ymin` and `ymax`. -- `pointrange` / `type_pointrange`: Combines points with error bars. +- `"pointrange"` / `type_pointrange()`: Combines points with error bars. - `"polygon"` / `type_polygon()`: Draws polygons. - `"polypath"` / `type_polypath()`: Draws a path whose vertices are given in `x` and `y`. -- `rect` / `type_area()`: Draws rectangles; requires `xmin`, `xmax`, `ymin`, and `ymax`. -- `ribbon` / `type_ribbon()`: Creates a filled area between `ymin` and `ymax`. -- `"segments"` / `type_segements()`: Draws line segments between pairs of points. +- `"rect"` / `type_rect()`: Draws rectangles; requires `xmin`, `xmax`, `ymin`, and `ymax`. +- `"ribbon"` / `type_ribbon()`: Creates a filled area between `ymin` and `ymax`. +- `"segments"` / `type_segments()`: Draws line segments between pairs of points. Visualizations: @@ -72,6 +72,7 @@ Visualizations: - `"histogram"` / `type_histogram()`: Creates a histogram of a single variable. - `"jitter"` / `type_jitter()`: Jittered points. - `"qq"` / `type_qq()`: Creates a quantile-quantile plot. +- `"ridge"` / `type_ridge()`: Creates a ridgeline (aka joy) plot. - `"spineplot"` / `type_spineplot()`: Creates a spineplot or spinogram. Models: @@ -87,6 +88,7 @@ Functions: - `type_hline()`: horizontal line(s). - `type_vline()`: vertical line(s). - `type_function()`: arbitrary function. +- `type_summary()`: summarize `y` by unique values of `x`. To see the difference between the convenience strings and their respective `type_*()` functional equivalents, let's quickly walk through two examples.