All Projects → r-lib → Ragg

r-lib / Ragg

Licence: other
Graphic Devices Based on AGG

Projects that are alternatives of or similar to Ragg

Luxor.jl
Simple drawings using vector graphics; Cairo "for tourists!"
Stars: ✭ 293 (+130.71%)
Mutual labels:  graphics, drawing, vector-graphics
Scour
Scour - An SVG Optimizer / Cleaner
Stars: ✭ 443 (+248.82%)
Mutual labels:  graphics, vector-graphics
Openvg
Tools for exploring OpenVG
Stars: ✭ 371 (+192.13%)
Mutual labels:  graphics, drawing
Macaw
Powerful and easy-to-use vector graphics Swift library with SVG support
Stars: ✭ 5,756 (+4432.28%)
Mutual labels:  graphics, drawing
cidrawing
A vector graphics library for Android
Stars: ✭ 35 (-72.44%)
Mutual labels:  drawing, vector-graphics
AsyPad
A simple drawing tool that can convert diagrams into Asymptote code.
Stars: ✭ 18 (-85.83%)
Mutual labels:  drawing, vector-graphics
Pixelfarm
From Vectors to (sub) Pixels, C# 2D Rendering Library
Stars: ✭ 120 (-5.51%)
Mutual labels:  drawing, vector-graphics
Graphics32
Graphics32 is a graphics library for Delphi and Lazarus. Optimized for 32-bit pixel formats, it provides fast operations with pixels and graphic primitives. In most cases Graphics32 considerably outperforms the standard TBitmap/TCanvas methods.
Stars: ✭ 238 (+87.4%)
Mutual labels:  graphics, vector-graphics
Perfect Freehand
Draw perfect pressure-sensitive freehand strokes.
Stars: ✭ 999 (+686.61%)
Mutual labels:  graphics, drawing
Atrament.js
A small JS library for beautiful drawing and handwriting on the HTML Canvas.
Stars: ✭ 1,045 (+722.83%)
Mutual labels:  graphics, drawing
Svg.skia
An SVG rendering library.
Stars: ✭ 122 (-3.94%)
Mutual labels:  graphics, vector-graphics
ludigraphix.github.io
Documentation for Ludigraphix
Stars: ✭ 21 (-83.46%)
Mutual labels:  drawing, vector-graphics
vec
Vector graphics software to generate HPGL output to drive a plotter
Stars: ✭ 19 (-85.04%)
Mutual labels:  drawing, vector-graphics
Graphicsrenderer
A drop-in UIGraphicsRenderer port -- CrossPlatform, Swift 4, Image & PDF
Stars: ✭ 85 (-33.07%)
Mutual labels:  graphics, drawing
powerpaint
Kreative PowerPaint - Library and Application for Bitmap and Vector Image Editing
Stars: ✭ 27 (-78.74%)
Mutual labels:  drawing, vector-graphics
Imagesharp
📷 A modern, cross-platform, 2D Graphics library for .NET
Stars: ✭ 5,186 (+3983.46%)
Mutual labels:  graphics, drawing
Picasso
Picasso is a high quality 2D vector graphic rendering library. It support path , matrix , gradient , pattern , image and truetype font.
Stars: ✭ 205 (+61.42%)
Mutual labels:  graphics, vector-graphics
Sketch
Sketch have a lot of basic functions to develop a drawing app for iPhone. Anyone can easily create drawing iOS Application.
Stars: ✭ 229 (+80.31%)
Mutual labels:  graphics, drawing
Macsvg
macSVG - An open-source macOS app for designing HTML5 SVG (Scalable Vector Graphics) art and animation with a WebKit web view ➤➤➤
Stars: ✭ 789 (+521.26%)
Mutual labels:  graphics, vector-graphics
Travelling Salesman Portrait
An experiment in R to convert photos into single-line-drawings
Stars: ✭ 81 (-36.22%)
Mutual labels:  drawing, rstats

ragg

R build status Codecov test coverage CRAN status Lifecycle: stable

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 <- 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 an agg_capture() device that lets you access the device 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 plotting
par(mai = c(0, 0, 0, 0))
plot(as.raster(scatter))

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].