| Title: | Extended Error Geoms for 'ggplot2' |
| Version: | 0.3.0 |
| Description: | Extends the 'ggplot2' error geoms. geom_error() accepts an 'error' aesthetic with auto-inference of the orientation. It also supports 'error_neg' and 'error_pos' for asymmetric cases, with full control over aesthetics per side, such as color, width etc... The package also includes a vignette covering it's main usecases - symmetric, asymmetric, one-sided, and per-side styling. |
| License: | MIT + file LICENSE |
| Encoding: | UTF-8 |
| RoxygenNote: | 7.3.3 |
| Imports: | cli, ggplot2 (≥ 3.4.0), rlang |
| Suggests: | knitr, purrr, rmarkdown, svglite, testthat (≥ 3.0.0), vdiffr (≥ 1.0.0) |
| Config/testthat/edition: | 3 |
| VignetteBuilder: | knitr |
| URL: | https://github.com/iamYannC/ggerror |
| BugReports: | https://github.com/iamYannC/ggerror/issues |
| NeedsCompilation: | no |
| Packaged: | 2026-04-20 07:01:05 UTC; 97253 |
| Author: | Yann Cohen |
| Maintainer: | Yann Cohen <yannco5@gmail.com> |
| Repository: | CRAN |
| Date/Publication: | 2026-04-21 19:53:03 UTC |
ggerror: Extended Error Geoms for 'ggplot2'
Description
Extends the 'ggplot2' error geoms. geom_error() accepts an 'error' aesthetic with auto-inference of the orientation. It also supports 'error_neg' and 'error_pos' for asymmetric cases, with full control over aesthetics per side, such as color, width etc... The package also includes a vignette covering it's main usecases - symmetric, asymmetric, one-sided, and per-side styling.
Author(s)
Maintainer: Yann Cohen yannco5@gmail.com (ORCID)
See Also
Useful links:
Error bars with automatic orientation
Description
A thin wrapper around ggplot2::geom_errorbar(),
ggplot2::geom_linerange(), ggplot2::geom_crossbar(), and
ggplot2::geom_pointrange() that accepts a single error aesthetic
and figures out orientation from the data. For asymmetric errors, use
error_neg + error_pos instead of error.
Usage
geom_error(
mapping = NULL,
data = NULL,
stat = "identity",
position = "identity",
...,
error_geom = "errorbar",
orientation = NA,
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE
)
geom_error_linerange(..., error_geom)
geom_error_crossbar(..., error_geom)
geom_error_pointrange(..., error_geom)
Arguments
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. |
stat |
The statistical transformation to use on the data. Defaults
to |
position |
Position adjustment. |
... |
Other arguments passed on to |
error_geom |
One of |
orientation |
Either |
na.rm |
If |
show.legend |
Logical. Should this layer be included in the legends? |
inherit.aes |
If |
Aesthetics
geom_error() requires x, y, and one of:
-
error— symmetric half-width applied along the non-categorical axis. -
error_neganderror_pos— asymmetric; the bar extendserror_negin the negative direction anderror_posin the positive direction along the non-categorical axis. For a one-sided bar, set the unused side to0explicitly.
Mixing error with error_neg / error_pos is an error, as is
providing only one of the asymmetric pair.
Fixed per-side styling can be supplied through ... with _neg and
_pos suffixes for colour, fill, linewidth, linetype, alpha,
and width.
These are fixed scalar parameters, not mapped aesthetics.
Examples
library(ggplot2)
ggplot(mtcars, aes(mpg, rownames(mtcars))) +
geom_point() +
geom_error(aes(error = drat))
ggplot(mtcars, aes(factor(cyl), mpg)) +
geom_point() +
geom_error(aes(error = drat), error_geom = "pointrange")
# Asymmetric: bar extends drat/2 below and drat above each point
ggplot(mtcars, aes(factor(cyl), mpg)) +
geom_point() +
geom_error(aes(error_neg = drat / 2, error_pos = drat))
# Style the negative and positive halves separately
ggplot(mtcars, aes(factor(cyl), mpg)) +
geom_point() +
geom_error(
aes(error_neg = drat / 2, error_pos = drat),
colour_neg = "steelblue",
colour_pos = "firebrick"
)