Skip to content

Plots combined with grid.arrange, cowplot or patchwork lose their alt text #19339

Open

Description

@gtritchie

Since #19337, the Plots pane image uses the alt text a plot's author supplies, such as ggplot2's `labs(alt = ...)`. That alt text is only found on the top-level grob drawn on the page. When several plots are combined, e.g. with `gridExtra::grid.arrange(p1, p2)`, `cowplot::plot_grid(p1, p2)` or patchwork, the alt text sits on the inner plots, so the pane falls back to "Plot N of M".

Steps to reproduce

```r
library(ggplot2)
p1 <- ggplot(mtcars, aes(mpg, wt)) + geom_point() + labs(alt = "Weight against fuel economy")
p2 <- ggplot(mtcars, aes(hp)) + geom_histogram() + labs(alt = "Histogram of horsepower")
gridExtra::grid.arrange(p1, p2)
```

Expected

The image's alt text includes the combined plots' descriptions.

Actual

The alt text is only "Plot 1 of 1".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions