View source: R/geom-arearange.R
| hd_geom_arearange | R Documentation |
Geometry layer for ribbon / confidence-interval charts. Unlike the other
hd_geom_*() functions, ymin and ymax are required named arguments
(they map to column names in spec$data) rather than optional ... extras.
This makes the contract explicit at the call site instead of burying
required information inside ....
hd_geom_arearange(ymin = NULL, ymax = NULL, ...)
ymin |
Character. Column name for the lower bound of the range. |
ymax |
Character. Column name for the upper bound of the range. |
... |
Additional optional arguments forwarded to the geom function
(e.g. |
An S3 object of class "hd_geom" for use with +.hd.
# Single series
spec_ar1 <- hd_spec(alco1,
x = "year",
y = "adj_enhet")
opts_ar <- hd_opts(
title = "Alcohol consumption with 95% CI",
subtitle = "Source: Norwegian Directorate of Health",
ylim = c(0, 30),
ylab = "Number of units alcohol"
)
hd_make(spec_ar1, "arearange", opts_ar,
ymin = "lower_enhet", ymax = "upper_enhet")
# Static ggplot2 version
hd_make(spec_ar1, "arearange", opts_ar,
ymin = "lower_enhet", ymax = "upper_enhet", mode = "static")
#' # Multi-series with group column
# Grouped by kjonn
spec_ar2 <- hd_spec(alco2,
x = "year",
y = "adj_enhet",
group = "kjonn")
hd_make(spec_ar2, "arearange", opts_ar,
ymin = "lower_enhet", ymax = "upper_enhet")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.