Open adeldaoud opened 5 years ago
FWIW, the way I do this at the moment is as follows:
library(tidyverse) # for %>% pipes
library(DiagrammeR)
library(DiagrammeRsvg) # for conversion to svg
library(rsvg) # for saving svg
grViz_object %>%
export_svg() %>%
charToRaw %>%
rsvg_pdf("./path_to_svg_file.svg")
Just for those of us in the "Ceci n'est pas une pipe' crew:
# 1. Make a play graph
tmp = DiagrammeR::grViz('digraph{a->b; c->a; c->b; c->d;}')
# 2. Convert to SVG, then save as png
tmp = DiagrammeRsvg::export_svg(tmp)
tmp = charToRaw(tmp) # flatten
rsvg::rsvg_png(tmp, "g.png") # saved graph as png in current working directory
Just for those of us in the "Ceci n'est pas une pipe' crew:
# 1. Make a play graph tmp = DiagrammeR::grViz('digraph{a->b; c->a; c->b; c->d;}') # 2. Convert to SVG, then save as png tmp = DiagrammeRsvg::export_svg(tmp) tmp = charToRaw(tmp) # flatten rsvg::rsvg_png(tmp, "g.png") # saved graph as png in current working directory
does anybody know why might this be affecting the final graph output? precisely, I have text in my graph in "Times New Roman" font, which is correctly displayed in R own viewer, but the .png file after I save it displays another font
I would like to save grviz objects to to pdf, png, or similar formats. However, I have searched the web and DiagrammeR's issues (e.g. #66 , #70 ) but could not judge whether there is an implementation ready.
Tried a version of the DiagrammerRsvg package code (#133 ) that worked, but it does not seem to be generalized and natively packaged into DiagrammeR to support export of grViz. Are there plans for this?
thanks