Learn R Programming

gghdx (version 0.2.0)

hdx_geom_defaults: Default HDX geometry aesthetics

Description

Default geometry aesthetics fitting the HDX design guide. Used in gghdx() to set default fill, color, size, and point geometry defaults, which is not possible using just theme_hdx().

Usage

hdx_geom_defaults(design = c("2025", "legacy"))

Value

A list of geometry defaults.

Arguments

design

Either "2025" (default), the current HDX visual design, or "legacy", the original pre-2025 defaults kept for backwards compatibility.

Details

Derived from the ggthemr methods.

As of the 2025 HDX website redesign, the defaults use the new primary blue and institutional data-grid blue. Pass design = "legacy" to instead get the original pre-2025 defaults (HDX sapphire and mint) for reports that aren't ready to move to the new look.

See Also

  • gghdx() for automatically setting default geometries, along with other styling.

  • ggplot2_geom_defaults() for the ggplot2 default aesthetics.

Examples

Run this code
library(purrr)
library(ggplot2)

# updating geom defaults (like default color of a point or fill for bar)
purrr::walk(
  hdx_geom_defaults(),
  ~ do.call(what = ggplot2::update_geom_defaults, args = .),
)

p <- ggplot(mtcars) +
  geom_point(
    aes(
      x = mpg,
      y = hp
    )
  )

# see the points are automatically in HDX primary blue
p

# need to reset back to the default geometries
purrr::walk(
  ggplot2_geom_defaults(),
  ~ do.call(what = ggplot2::update_geom_defaults, args = .)
)

# now the points are back to default black
p

Run the code above in your browser using DataLab