Need help with ragg?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

r-lib
134 Stars 11 Forks Other 315 Commits 5 Opened issues

Description

Graphic Devices Based on AGG

Services available

!
?

Need anything else?

Contributors list

ragg

R build
status Codecov test
coverage CRAN
status Lifecycle:
stable <!-- badges: end -->

This package provides graphic devices for R based on the AGG library developed by the late Maxim Shemanarev. AGG provides both higher performance and higher quality than the standard raster devices provided by grDevices. For a comparison with the default devices, see the performance and quality vignettes.

Installation

The package can be installed from CRAN with

install.packages('ragg')
or, if the development version is desired, directly from github:
# install.packages('devtools')
devtools::install_github('r-lib/ragg')

Use

ragg provides drop-in replacements for the png, jpeg, and tiff graphic devices provided by default from the grDevices packages and can both produce png, jpeg and tiff files. Notable features, that sets itself apart from the build-in devices, includes:

  • Faster (up to 40% faster than anti-aliased cairo device)
  • Direct access to all system fonts
  • Advanced text rendering, including support for right-to-left text, emojis, and font fallback
  • High quality anti-aliasing
  • High quality rotated text
  • Support 16-bit output
  • System independent rendering (output from Mac, Windows, and Linux should be identical)

You can use it like any other device. The main functions are

agg_png()
,
agg_jpeg()
and
agg_tiff()
, all of which have arguments that closely match those of the
png()
,
jpeg()
and
tiff()
functions, so switching over should be easy.
library(ragg)
library(ggplot2)

file

Further, it provides an

agg_capture()
device that lets you access the device buffer directly from your R session.
cap 

Use ragg with knitr

knitr supports png output from ragg by setting

dev = "ragg_png"
in the chunk settings or globally with
knitr::opts_chunk$set(dev =
"ragg_png")
.

Use ragg in RStudio

ragg can be used as the graphic back-end to the RStudio device (for RStudio >= 1.4) by choosing AGG as the backend in the graphics pane in general options (see screenshot)

Setting ragg as backend in RStudio

Code of Conduct

Please note that the ‘ragg’ project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.