Package 'ggalttext'

Title: Make 'ggplot2' Fully Accessible by Generating Alternative Text
Description: Generate alternative texts from 'ggplot2' objects.
Authors: Joseph Barbier [aut, cre]
Maintainer: Joseph Barbier <[email protected]>
License: MIT + file LICENSE
Version: 0.2.0
Built: 2026-05-28 06:36:37 UTC
Source: https://github.com/y-sunflower/ggalttext

Help Index


Generate alternative text from a ggplot2 object

Description

generate_alt_text() takes any ggplot2 object and generates a string that describes what contains the chart.

The description isn't meant to exactly describe the chart, nor how it was made. Instead, it tries to be short and gives an overview of what's inside the chart such as:

  • the kind of chart(s)

  • the number of chart(s) for facets

  • the title, subtitle and caption

Learn more: https://www.section508.gov/create/alternative-text/

Usage

generate_alt_text(p, from = c("default", "auto", "origin"), lang = "en")

Arguments

p

A ggplot object.

from

Method used to select alt text. Since ggplot2 objects can include built-in alt text (via labs(alt = "Here goes the text")), choose whether to use that text or the one generated by ggalttext. - "default": always generate alt text with ggalttext. - "auto": use existing alt text when it is non-empty; otherwise generate alt text with ggalttext. - "origin": always return ggplot2::get_alt_text(p) as-is.

lang

Language used for generated text. Defaults to "en" (English). Supported values are "en", "fr" (French), and "de" (German).

Value

A string