Skip to content

Conversation

teunbrand
Copy link
Collaborator

This PR aims to fix #4795, by allowing alt to be a function that takes the plot as input.

devtools::load_all("~/packages/ggplot2")
#> ℹ Loading ggplot2

p <- ggplot(mpg, aes(class)) +
  geom_bar() +
  labs(alt = ~ BrailleR::VI(.x)$text)

cat(get_alt_text(p), sep = "\n")
#> This is an untitled chart with no subtitle or caption.
#> It has x-axis 'class' with labels 2seater, compact, midsize, minivan, pickup, subcompact and suv.
#> It has y-axis 'count' with labels 0, 20, 40 and 60.
#> The chart is a bar chart with 7 vertical bars.
#> Bar 1 is centered horizontally at 2seater, and spans vertically from 0 to 5.
#> Bar 2 is centered horizontally at compact, and spans vertically from 0 to 47.
#> Bar 3 is centered horizontally at midsize, and spans vertically from 0 to 41.
#> Bar 4 is centered horizontally at minivan, and spans vertically from 0 to 11.
#> Bar 5 is centered horizontally at pickup, and spans vertically from 0 to 33.
#> Bar 6 is centered horizontally at subcompact, and spans vertically from 0 to 35.
#> Bar 7 is centered horizontally at suv, and spans vertically from 0 to 62.

Created on 2022-12-03 by the reprex package (v2.0.1)

@teunbrand teunbrand added the feature a feature request or enhancement label Jul 9, 2023
Copy link
Member

@thomasp85 thomasp85 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

teunbrand and others added 3 commits May 20, 2024 10:13
Merge branch 'main' into alt_function

# Conflicts:
#	tests/testthat/_snaps/labels.md
#	tests/testthat/test-labels.r
@teunbrand teunbrand merged commit 9202a47 into tidyverse:main May 20, 2024
@teunbrand teunbrand deleted the alt_function branch May 20, 2024 08:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Accessibility] Allow alt to take a function
2 participants