Package: ggspec 0.1.0

ggspec: Extract and Compare 'ggplot2' Plot Specifications as Tidy Data Frames

Inspects 'ggplot' objects by extracting their full declarative specification - layers, aesthetic mappings, scales, facets, coordinate systems, and labels - as tidy data frames. A second tier of functions enables structural comparison of two 'ggplot' objects, supporting automated plot testing, auditing, and framework-agnostic grading workflows. Unlike 'ggcheck', which is designed exclusively for 'learnr'/'gradethis' pipelines and returns ad-hoc objects, 'ggspec' returns rectangular, pipeable output and does not require any grading framework as a dependency.

Authors:Clement Lee [aut, cre]

ggspec_0.1.0.tar.gz
ggspec_0.1.0.zip(r-4.7-any)ggspec_0.1.0.zip(r-4.6-any)ggspec_0.1.0.zip(r-4.5-any)
ggspec_0.1.0.tgz(r-4.6-any)ggspec_0.1.0.tgz(r-4.5-any)
ggspec_0.1.0.tar.gz(r-4.7-any)ggspec_0.1.0.tar.gz(r-4.6-any)
ggspec_0.1.0.tgz(r-4.6-emscripten)
manual.pdf |manual.html✨
DESCRIPTION |NEWS
card.svg |card.png
ggspec/json (API)

# Install 'ggspec' in R:
install.packages('ggspec', repos = c('https://clement-lee.r-universe.dev', 'https://cloud.r-project.org'))

Bug tracker:https://github.com/clement-lee/ggspec/issues

On CRAN:

Conda:

4.88 score 10 scripts 327 downloads 30 exports 25 dependencies

Last updated from:1f4e2bf7d3. Checks:9 OK. Indexed: yes.

TargetResultTimeFilesSyslog
linux-develOK125
source / vignettesOK180
linux-releaseOK126
macos-releaseOK191
macos-oldrelOK170
windows-develOK89
windows-releaseOK88
windows-oldrelOK89
wasm-releaseOK112

Exports:assert_ggplotcanoncheck_plotcompare_conceptualcompare_plotscompare_visualenrich_specequiv_aesequiv_coordequiv_dataequiv_facetsequiv_labelsequiv_layersequiv_paramsequiv_plotequiv_renderedequiv_scalesexpect_equiv_plothas_layeris_ggplotmapping_existsn_layersspec_aesspec_coordspec_dataspec_facetsspec_labelsspec_layersspec_plotspec_scales

Dependencies:clicpp11dplyrfarvergenericsggplot2gluegtableisobandlabelinglifecyclemagrittrpillarpkgconfigR6RColorBrewerrlangS7scalestibbletidyselectutf8vctrsviridisLitewithr

Equivalence Patterns and Canonicalisation Modes
Introduction | 1. Inheritance transparency | 1.1 Global, local, and mixed aes() | 1.2 Global vs per-layer data | 1.3 Layer order | 2. Bar chart equivalence | 2.1 Direct equivalents | 2.2 geom_col() — structural mode required | 2.3 coord_flip() — visual mode required | 2.4 Scale name vs labs() — visual mode required | 3. Count plot equivalence | 3.1 geom_count() variants — direct equivalents | 3.2 geom_point(aes(size = n)) + pre-counted data — separate equivalence group | 3.5 Pre-counted bar charts — exhausting the equivalence cases | 4. Histogram binning variants | 5. Pending work | 5.1 Cross-geom stat equivalence | 5.2 Multi-dataset layer verification

Last update: 2026-05-06
Started: 2026-04-14

Extracting Plot Specifications with ggspec
Introduction | A motivating example | Layer specification | Controlling inheritance | Aesthetic specification (long format) | Scale specification | Facet specification | Label specification | Coordinate system specification | The master summary: spec_plot()

Last update: 2026-05-06
Started: 2026-04-09

Plot Grading and Testing with ggspec
Introduction | Comparing two plots with equiv_plot() | Running individual checks | The exact argument | Framework-agnostic checking with check_plot() | Swapping in a learnr/gradethis fail function | Using expect_equiv_plot() in testthat | Inspecting the diff | Comparing layer parameters | Canonicalisation-aware comparison with compare_plots() | Modes | Using a mode in check_plot() | What each mode covers | Summary of available checks

Last update: 2026-05-06
Started: 2026-04-09

Readme and manuals

Help Manual

Help pageTopics
Assert that an object is a ggplotassert_ggplot
Canonicalise a ggplot specificationcanon
Framework-agnostic plot checkcheck_plot
Compare two ggplot objects for conceptual similaritycompare_conceptual
Compare two ggplot objectscompare_plots
Compare two ggplot objects for visual equivalencecompare_visual
Enrich a plot's layer specification with build-derived default informationenrich_spec
Compare aesthetic mappings of two ggplot objectsequiv_aes
Compare coordinate systems of two ggplot objectsequiv_coord
Compare the data of a layer in two ggplot objectsequiv_data
Compare facet specification of two ggplot objectsequiv_facets
Compare labels of two ggplot objectsequiv_labels
Compare layer structure of two ggplot objectsequiv_layers
Compare parameters of a specific layer in two ggplot objectsequiv_params
Compare two ggplot objects across multiple dimensionsequiv_plot
Compare the rendered (built) layer data of two ggplot objectsequiv_rendered
Compare scales of two ggplot objectsequiv_scales
testthat expectation for plot equivalenceexpect_equiv_plot
Test whether a plot contains a given layerhas_layer
Test whether an object is a ggplotis_ggplot
Test whether a specific aesthetic mapping exists in a plotmapping_exists
Count the number of layers in a ggplotn_layers
Extract aesthetic mappings as a long-format tidy data framespec_aes
Extract coordinate system specification as a tidy data framespec_coord
Extract the dataset table for a ggplot objectspec_data
Extract facet specification as a tidy data framespec_facets
Extract plot labels as a tidy data framespec_labels
Extract layer specifications as a tidy data framespec_layers
Extract the full plot specification as a master tidy data framespec_plot
Extract scale specifications as a tidy data framespec_scales