- Notifications
You must be signed in to change notification settings - Fork30
Graphic Devices Based on AGG
License
Unknown and 2 other licenses found
Licenses found
r-lib/ragg
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
This package provides graphic devices for R based on the AGG librarydeveloped by the late Maxim Shemanarev. AGG provides both higherperformance and higher quality than the standard raster devices providedby grDevices. For a comparison with the default devices, see theperformance andquality vignettes.
The package can be installed from CRAN withinstall.packages('ragg')or, if the development version is desired, directly from github:
# install.packages('pak')pak::pak('r-lib/ragg')
ragg provides drop-in replacements for the png, jpeg, and tiff graphicdevices provided by default from the grDevices packages and can bothproduce png, jpeg and tiff files. Notable features, that sets itselfapart 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 Linuxshould be identical)
You can use it like any other device. The main functions areagg_png(),agg_jpeg() andagg_tiff(), all of which have argumentsthat closely match those of thepng(),jpeg() andtiff()functions, so switching over should be easy.
library(ragg)library(ggplot2)file<-knitr::fig_path('.png')on_linux<- tolower(Sys.info()[['sysname']])=='linux'fancy_font<-if (on_linux)'URW Chancery L'else'Papyrus'agg_png(file,width=1000,height=500,res=144)ggplot(mtcars)+ geom_point(aes(mpg,disp,colour=hp))+ labs(title='System fonts — Oh My! 😱')+ theme(text= element_text(family=fancy_font))invisible(dev.off())knitr::include_graphics(file)
Further, it provides anagg_capture() device that lets you access thedevice buffer directly from your R session.
cap<- agg_capture(width=1000,height=500,res=144)plot(1:10,1:10)scatter<- cap()invisible(dev.off())# Remove margins from raster plottingpar(mai= c(0,0,0,0))plot(as.raster(scatter))
knitr supports png output from ragg by settingdev = "ragg_png" in thechunk settings or globally withknitr::opts_chunk$set(dev = "ragg_png").
ragg can be used as the graphic back-end to the RStudio device (forRStudio >= 1.4) by choosingAGG as the backend in the graphics panein general options (see screenshot)
Please note that the ‘ragg’ project is released with aContributor Codeof Conduct. Bycontributing to this project, you agree to abide by its terms.
About
Graphic Devices Based on AGG
Topics
Resources
License
Unknown and 2 other licenses found
Licenses found
Code of conduct
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.



