← Back to all sparks
A

afcharts

INFRA · APIS
Velocity0.0

Produce Charts Following UK Government Analysis Function Guidance

UK government chart styling in ggplot2, chasing ggplot2 v4 and stretching its palette to five.

data-visualisationgovernment-statisticsggplot2colour-palettesaccessibility
Current state
afcharts supplies the UK Analysis Function's chart styling for ggplot2, as a theme, colour and fill scales, and a use_afcharts() call that applies the styling globally. Version 0.5.1 extends the sequential palette to five shades so it can carry quintile data such as deprivation bands, renames the na_colour argument to na.value, and adds a reset argument to switch the styling back off. The package began as a first release derived from sgplot and has had three releases in roughly two years.
Where it's heading
The work splits between palette design and keeping the styling composable. On the design side the sequential palette growing to five shades is driven by a specific reporting need rather than aesthetics, since quintiles are a standard unit in UK official statistics. On the mechanical side, the na.value rename was forced by ggplot2 v4.0.1, theme_af() now respects options set by an earlier use_afcharts() call, and a reset argument acknowledges that global styling needs an off switch. These are the problems a styling package hits once people use it inside larger documents.
Prediction
Expect continued adjustment to ggplot2 v4, since the na.value rename is unlikely to be the only argument affected, and further palette work driven by the reporting formats government analysts actually publish. As a sibling to aftables in the same Analysis Function family, it is likely to keep tracking that guidance rather than setting its own direction.

Recent moves

  1. 5mo ago

    Sequential palette reaches five shades for quintile data

    Adds darkest and lightest blues so the sequential palette can represent five categories, which is what deprivation quintiles and similar official statistics need, and renames na_colour to na.value for ggplot2 v4.0.1 compatibility. A reset argument for use_afcharts() and theme_af() honouring earlier styling calls both address the awkwardness of applying styling globally.

    View source ↗
  2. 1y ago

    Namespace and argument-passing fixes

    Fixes functions that failed when called directly without attaching the package, corrects argument passing from use_afcharts() to theme_af(), and downgrades a warning to a message when a two-colour palette substitutes for the main one. Small corrections to how the package behaves when used in less conventional ways.

    View source ↗
  3. 1y ago

    First release, derived from sgplot

    The initial release, described as based on sgplot, bringing that styling work under the Analysis Function name. A rebrand of an existing codebase rather than new capability entering the ecosystem, which is the same move aftables made when it was renamed from a11ytables.

    View source ↗