ropensci / rsvg

SVG renderer for R based on librsvg2
Other
95 stars 1 forks source link

comparing performance with ragg/base #16

Open jeroen opened 4 years ago

jeroen commented 4 years ago
library(ggplot2)
unlink(c("base.png", "ragg.png", 'rsvg.png'))

test_plot <- function(){
  ggplot(mtcars) +
    geom_point(aes(mpg, disp, colour = hp)) +
    labs(title = 'System fonts — Oh My!') +
    theme(text = element_text(family = 'Papyrus'))
}

system.time({
  png('base.png', width = 1080, height = 720, res = 144)
  print(test_plot())
  invisible(dev.off())
})

library(ragg)
system.time({
  agg_png('ragg.png', width = 1080, height = 720, res = 144)
  print(test_plot())
  invisible(dev.off())
})

library(svglite)
system.time({
  s <- svgstring(width = 1080/144, height = 720/144)
  print(test_plot())
  buf <- charToRaw(s())
  invisible(dev.off())
  rsvg::rsvg_png(buf, width=1080, height = 720, 'rsvg.png')
})