RStudio does not export colors/transparencies (within tables) - package "gt"

The tables I plot do not show any color, not even the default grey shading.
The problem persist after saving them as .png or .pdf.
The problem is some R (?) setting in my laptop, if I run the same code on another pc all the colors are in their place.
Colors work fine on other packages such as ggplot2.

Does anyone know what does the package use to add colors? (So I can generalize and track down the mistake origin)
Which one might be the source of the problem?

Thanks a lot

Installing the latest version of RStudio solved the problem in the viewer tab (no idea why though).
But when saving the gt object it does not have colors.

I tried to add device=cairo_ps which solved the problem of exporting transparency for many users but it does not run in gtsave()

Hi @havefun! Welcome!

For image outputs, gt::gtsave() first creates a temporary HTML file, then it uses webshot to take a screenshot of the rendered HTML (webshot, for its part, is using the headless browser PhantomJS to do its work). That doesn't answer exactly what's going wrong with the colors in your tables, but maybe it gives you some ideas of where to start looking?

Of course, gt is still under development, so if you can provide some code that reproduces the problem you see, that could potentially be helpful for filing a bug report. You said that this problem occurred on some machines but not others, so a good example would probably include:

  • Code for a table with some colors, using one of gt's built-in datasets
  • A screenshot (taken by you, by hand!) of what that table looks like when rendered in a regular web browser (e.g., put it in an R Markdown document and render to HTML, view in browser, and screenshot)
  • The image file result you get from running gtsave() on the same table
  • As much system info as you can provide: OS version, R version, sessionInfo() output from a session where you ran gtsave(), and what version of PhantomJS you have installed (and how you installed it)

Someone (was it you?) has recently posted an issue to gt GitHub issue tracker about this same problem, but there's no reproducible example yet:


Addng a good, minimal example to that issue is a great way to contribute! :grinning:

1 Like