Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
/raggPublic

Graphic Devices Based on AGG

License

Unknown and 2 other licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md
Unknown
LICENSE.note
NotificationsYou must be signed in to change notification settings

r-lib/ragg

Codecov test coverageCRAN statusLifecycle: stableR-CMD-check

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.

Installation

The package can be installed from CRAN withinstall.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 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))

Use ragg with knitr

knitr supports png output from ragg by settingdev = "ragg_png" in thechunk settings or globally withknitr::opts_chunk$set(dev = "ragg_png").

Use ragg in RStudio

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)

Setting ragg as backend in RStudio

Code of Conduct

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

Unknown
LICENSE
MIT
LICENSE.md
Unknown
LICENSE.note

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Contributors17


[8]ページ先頭

©2009-2025 Movatter.jp