Reputation: 169
What is the best way to save a visualization from the dm package? I am currently using the viewer to save images made with dm_draw
, but this is producing low resolution images and is not ideal.
Example:
dm_nycflights13() %>%
dm_draw()
I've tried adding png(file_name = "filename.png"
and dev.off()
to sandwich the dm visualization, but haven't had any luck.
Upvotes: 2
Views: 194
Reputation: 436
You could use the saveWidget function from the htmlwidgets
R package. You can change the selfcontained parameter, depending on if you want to save the HTML as a single self-contained file or not.
htmlwidgets::saveWidget(widget = diagr, file = "diagram.html", selfcontained = TRUE)
Upvotes: 2
Reputation: 169
For anyone else looking for this, the result of dm_draw() can be piped into DiagrammeRsvg::export_svg().
Upvotes: 2