rstudio / rstudio/gt

extend ggplot_image() to other output formats

Open
#2,002 0 comments 0 reactions 1 assignee View on GitHub

@rich-iannone is already working on this.

Since Jun 18, 2025.

Type: ★ Enhancement
Dominant language
R
Stars
2.2k
Forks
225
Avg merge
1d 19h
Merged PRs (30d)
11

Description

Prework

Thanks for all the work you've done on this package :)

Proposal

Currently ggplot_image() only works for HTML since it uses local_image(). If it were updated to use fmt_image() functionality then ggplots within gt outputs could go to other formats more easily.

library(ggplot2)
library(gt)
library(dplyr)

plot_object <- ggplot(data = mtcars, mapping = aes(x = mpg, y = cyl)) +
  geom_point() 


filename <- "temp_ggplot.png"

# Save PNG file to disk
ggplot2::ggsave(
  filename = filename,
  plot = plot_object,
  device = "png",
  dpi = 100,
  width = 5,
  height = 5
)


gt <- tibble(filename) |>
  gt() |>
  fmt_image(columns = everything(), sep = ",", width = "6in")
  

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.