ggconsulting 0.1.1
This patch release follows the bundled reference corpus into theme_finance(), teaches ct_finish() to mirror axes and defer to caller-supplied scales, records dataset provenance, and starts organised documentation: a gallery article, provenance notes with source credits, and an R-universe distribution.
Data-aware polish
-
ct_finish(mirror_y = TRUE)repeats the y-axis ticks on the opposite edge of the panel, without labels, so the eye can track a level across a wide panel in the absence of gridlines. It pairs with the bare axis oftheme_finance(). - Auto expansion in
ct_finish()now defers to any positional scale supplied by the caller, soscale_y_continuous(labels = ...)keeps its labels instead of being silently replaced. Set the expansion in the same call when you need both labels and headroom.
Themes
-
theme_finance()follows the institutional finance chart packs the archetype is drawn from: humanist sans typography (Source Sans 3with an Inter / Helvetica Neue / Arial fallback chain) instead of serif, no gridlines, and y-axis ticks to read levels against. Pair withct_finish(mirror_y = TRUE)to repeat the ticks on the right edge of wide panels.
Fonts
-
install_consulting_fonts()now installs to the per-user Windows Fonts directory by default and registers the installed fonts for the active R session.
Distribution and documentation
- The package is available from R-universe, with source and binary builds for supported platforms.
- The README is rewritten against the current API, with a quick start that demos
ct_finish()end labels and a Why ggconsulting? summary. The Codecov badge is replaced by the R-universe version badge. - New article “Themes and palettes”: a gallery with one plot per archetype preset plus the discrete and continuous scales, indexed under a pkgdown Articles navbar entry. The site gains a Datasets reference section.
- Dataset provenance is recorded in
data-raw/README.mdand mirrored into the dataset help pages. Beyond new disclaimers, this corrects thebr_macrodescription (BCB SGS series 4189 and 3696; sale-rate USD/BRL; monthly source series rather than aggregated dailies) and credits B3 foribov_sectors. Bundled snapshots note that BCB, IBGE, and B3 do not endorse the package. - The package has a hex logo, regenerable with
data-raw/create_hexlogo.R, shown on the package help page.
ggconsulting 0.1.0
First public release. ggconsulting is an opinionated ggplot2 extension for executive-grade consulting output: archetype themes, palettes, scales, locale-aware label helpers, and a data-aware polish layer.
The package is experimental. The public API is being shaped against real consulting decks, so expect breaking changes through the 0.x series.
Requirements
- Requires ggplot2 >= 4.0.0 and R >= 4.1. The themes are built on ggplot2 4.x API —
theme_sub_*()helpers,element_geom(), andfrom_theme()linkage — and will not work on ggplot2 3.x.
Themes
-
ct_theme()composes a theme frompalette,font,font_fallback,density, andcontextarguments. The palette’s main colour is routed throughelement_geom(ink = ...), sofrom_theme()-aware geoms pick it up without an explicitscale_color_*()call. -
theme_strategy()— minimal, generous whitespace, navy default. -
theme_finance()— serif preset (Source Serif 4 → Georgia → Times New Roman → serif) with a regular-weight title, lighter major gridlines, and denser defaults (density = "tight",context = "report") tuned for printed pages rather than slides. Defaults tofinance_classic. -
theme_editorial()— serif preset with an italic subtitle and a larger, tighter-leaded title. Defaults toeditorial_warm. -
ct_theme(paper = ...)sets the figure ground. Pass"cream"(Financial Times),"warm_grey"(The Economist),"white", or any colour R recognises. Becausetheme_minimal()leaves the panel background blank, filling the plot background alone gives a uniform ground with no panel-versus-plot seam. Settingpaperalso warms the major gridline to match. The archetypes forward it, sotheme_editorial(paper = "cream")works; cream is opt-in rather than the editorial default.
Palettes and scales
- Eleven palettes of six colours each, in three families: five strategy (
strategy_navy,strategy_emerald,strategy_crimson,strategy_azure,strategy_slate), three finance (finance_classic,finance_steel,finance_burgundy), and three editorial (editorial_warm,editorial_clay,editorial_oxide). -
ct_palette()returns a palette’s colours, subsets ton, or — called with no arguments — lists every available palette name. -
scale_color_ct()/scale_fill_ct()— discrete scales. When the data needs more levels than the palette holds, colours are interpolated and a warning points at the continuous scales instead. -
scale_color_ct_c()/scale_fill_ct_c()— continuous variants, withdirection = -1to reverse. - British-spelling aliases:
scale_colour_ct(),scale_colour_ct_c(). -
ct_palette_show()— swatch preview for one palette, a custom hex vector, or every shipped palette faceted.
Locale and formatters
-
ct_locale("pt-BR" | "en-US")— session-scoped locale switch stored inoptions(ggconsulting.locale). It does not touchSys.setlocale(); the package ships its own month tables and formatting marks, so output is identical across Windows, Linux, and macOS. -
fmt_number()— locale-aware numbers (1.234,5/1,234.5). -
fmt_brl()— Brazilian Real, alwaysR$with a non-breaking space regardless of the active locale.style = "accounting"wraps negatives in parentheses. -
fmt_currency()— uses the active locale’s currency symbol. -
fmt_pct()— fraction to percent (0.5→"50%"). -
fmt_delta()— always-signed percentage-point deltas (+1,2pp). -
fmt_month()—Date/POSIXctto a localised month string.
Data-aware polish
-
ct_finish()runs after the geom layer is built, via aggplot_add()S3 method, and inspects the plot to apply:- value labels above bars or beside points (
values = TRUE) - reordering of a categorical x by y (
sort = "asc" | "desc") - label formatting by shortcut (
label_fmt = "brl" | "number" | "pct" | "delta") or a user-supplied function - highlighting of specific x values in the theme’s main colour, muting the rest with
muted_color(default#A8A4A0, a warm-leaning neutral that reads against both cool and warm palettes) - end labels on the last point of each line series (
end_labels = TRUE), or only in the first panel of a faceted plot (end_labels = "first_facet"), which replaces a legend across small multiples - a filled point at each series’ last observation (
end_points = TRUE) - a right-hand y axis (
axis_y = "right"), applied throughguide_axis()so it leaves ascale_y_*()call of your own alone - geom-aware scale expansion (
expand = "auto") — headroom above columns, right-side room for line endpoints
end_labelsnow acceptsDateandPOSIXctx aesthetics, which it previously rejected. Auto expansion no longer adds a second x scale over the one end labels set, and neither replaces an x scale supplied by the caller. - value labels above bars or beside points (
Geom wrappers and defaults
-
ct_col(),ct_line(),ct_point()— thin wrappers over the corresponding ggplot2 geoms with consulting defaults as formals, for overriding at the call site. -
ct_set_defaults()/ct_unset_defaults()apply and cleanly revert package-wide aesthetic defaults viaupdate_geom_defaults(). Applied on attach; opt out withoptions(ggconsulting.autoload = FALSE).
Fonts
-
install_consulting_fonts()downloads the five archetype font families from Google Fonts (Inter, Source Sans 3, Lato, Source Serif 4, IBM Plex Sans — all OFL or Apache-2.0) and installs them into a platform-appropriate user font directory.Because that writes outside the R session, it asks for confirmation first when run interactively and refuses to run otherwise. Pass an explicit
dest, or setoptions(ggconsulting.font_consent = TRUE), to install unattended. has_font()reports whether a family is available, checking both fonts installed on the operating system and fonts registered for the session withsystemfonts::register_font(). This matters for client brand fonts, which are commonly registered from a file rather than installed:ct_theme(font = "ClientSans")now honours a registeredClientSansinstead of falling through to thefont_fallbackchain.
