Skip to contents

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 ....

Usage

hd_geom_arearange(ymin, ymax, ...)

Arguments

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. show_line = FALSE, single_colour = "#025169"). Run geom_args("arearange") for the full list.

Value

An S3 object of class "hd_geom" for use with +.hd.

Examples


# 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", backend = "ggplot2") #> Scale for y is already present. #> Adding another scale for y, which will replace the existing scale. #' # 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")