R Graphics Devices for Vector Graphics Output

Vector Graphics devices for Microsoft PowerPoint and Excel. Functions extending package 'officer' are provided to embed 'DrawingML' graphics into 'Microsoft PowerPoint' presentations and 'Microsoft Excel' workbooks.

Travis-CI BuildStatus Buildstatus version cranlogs Active

rvg is providing two graphics devices that produces Vector Graphics outputs in DrawingML format for Microsoft PowerPoint with dml_pptx and for Microsoft Excel with dml_xlsx. Theses formats let users edit the graphic elements (editable graphics) within PowerPoint or Excel and have a very good rendering.

These raw XML outputs cannot be used as is. Functions ph_with_vg() and ph_with_vg_at() can be used with package officer to add vector graphics in PowerPoint documents.

doc <- read_pptx()
doc <- add_slide(doc, layout = "Title and Content", master = "Office Theme")
doc <- ph_with_vg(doc, code = barplot(1:10), type = "body")
print(doc, target = "my_plot.pptx")

Function xl_add_vg() is the equivalent for Excel workbooks.

doc <- read_xlsx()
doc <- xl_add_vg(doc, sheet = "Feuil1", code = print(gg), 
  width = 6, height = 6, left = 1, top = 2 )
print(doc, target = "vg.xlsx")

By default, theses graphics are editable, element edition can be disabled with option editable = FALSE. For more details, read officer article graphics.

You can get the development version from GitHub:


Install the CRAN version:



rvg 0.2.0


  • dsvg is now living in ggiraph package

rvg 0.1.9


  • add path method to PowerPoint device. As an effect ggplot2::geom_sf is now supported.
  • argument type of function ph_with_vg now default to "body".


  • dml_docx is deprecated and will be removed in later versions. It was maintained for compatibility reasons with package ReporteRs. As ReporteRs will be removed from CRAN 2018-07-16, this function has no more reason to exist.

rvg 0.1.8

  • fix encoding issues with Windows platforms.

rvg 0.1.7

  • add argument ggobj to ph_with_vg() and ph_with_vg_at(). It can be used as replacement to code=print(gg) when gg is a ggplot object.

  • new function xl_add_vg() to add vector graphics produced from R into Excel workbooks. This requires officer >= 0.2.0.

rvg 0.1.6

  • update with officer 1.8

rvg 0.1.5

  • update with gdtools 1.6
  • raster ids are now registered

rvg 0.1.4

  • raster images dpi has been increased
  • new 'ph_with_vg_at' methods for package officer

rvg 0.1.3

  • new 'body_add_vg' and 'ph_with_vg' methods for package officer
  • deletion of write_* functions, these are now available in officer (functions print)

rvg 0.1.2

  • add donttest tags in all examples to avoid long runs due to fontconfig initialisation
  • change textbox in Word graphics so that text auto-adjusts.

rvg 0.1.1

  • adapt code to gdtools 0.1.1

rvg 0.1.0

  • adapt code to xml2 1.0 (use xml_find_first instead of deprecated xml_find_one)

rvg 0.0.9

New features

  • new device driver for Microsoft Excel documents
  • add function write_xlsx

Bug fixes

  • make cliping region id unique in dsvg

rvg 0.0.8

Bug fixes

  • fix rectangle clipping
  • stop wrapping text in DrawingML devices

rvg 0.0.7

New features

  • implementation of clipping (algorithms by Francois Brunetti).
  • new function set_attr to set attributes to graphical elements without dependency to jquery nor bootstrap (suggested by Bob Rudis).

rvg 0.0.6

Bug fixes

  • plot size was truncated to integers

  • lines with opacity were not displayed

New features

  • grid support for interactive points, polygons, polylines, rectangles, segments and text

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.


0.2.5 by David Gohel, 10 months ago


Report a bug at https://github.com/davidgohel/rvg/issues

Browse source code at https://github.com/cran/rvg

Authors: David Gohel [aut, cre] , Bob Rudis [ctb] (the javascript code used by function set_attr) , Francois Brunetti [ctb] (clipping algorithms)

Documentation:   PDF Manual  

GPL-3 license

Imports grDevices, Rcpp, officer, gdtools, xml2, rlang

Suggests rmarkdown, htmltools, testthat, covr, grid, knitr

Linking to Rcpp, gdtools

Imported by eoffice, officedown, rrtable, thinkr.

Suggested by bfw, esquisse.

See at CRAN