Introducing minidrawio - create simple documents in R


minidrawio is a package for creating simple, single-page documents. is a vector diagram format and a website for editing such diagrams.

minidrawio is an R package which allows you to create diagrams.

It’s killer feature is that the website is an interactive vector diagram editor. Any diagram you create with minidrawio can be uploaded to the site (for free!) and edited.

Currently, minidrawio is not a very complete implementation. Its initial purpose is to contain enough functionality to be able to use it as a graphics device backend. (devoutdrawio is coming soon!)


You can install from GitHub with:

# install.packages("remotes")

Future possibilities

  • Lots more documentation and examples
  • Feature parity with what the web interface offers.
    • e.g. be able to programatically add any of the library of shapes and link them together correctly in a hierarchy.
    • text rotation, shadows, grid layouts, etc, etc.

Simple example of building a document

# This is the basic setup needed for every drawio file
doc   <- DrawIODocument$new()
dia   <- doc$diagram(id = 'aaa')
graph <- dia$mxGraphModel()
root  <- graph$root()
root$mxCell(id = 0)
root$mxCell(id = 1, parent = 0)

# Now add some text and other elements
root$rect(x = 50, y = 50, width = 100, height = 50, size = 0, colour = NA, fill = 'green', alpha = 0.2)
root$text(x = 150, y = 50, colour = 'blue', text = "Hello Rstats", fontsize = 50)
root$line(x1 = 100, y1=100, x2=200, y2 = 200)
root$circle(0, 0, 20, fill = 'red')
root$polygon(c(0, 200, 200), c(0, 0, 200), fill = 'none')

# Save to drawio/XML format

You can download the xml, or click the link below to take you directly to the plot on

Click to view/edit the plot on

Screenshot of plot in

Edit in drawio

Now that the diagram is saved in drawio format, we can load it up in the drawio web app and edit it to our heart’s content!