Export a graph to a variety of file formats, including image formats such as PNG, PDF, SVG, and PostScript, and graph file formats such as GEXF.

export_graph(graph, file_name = NULL, file_type = NULL, title = NULL,
  width = NULL, height = NULL)

Arguments

graph

a graph object of class dgr_graph.

file_name

the name of the exported file (including it's extension).

file_type

the type of file to be exported. Options for graph files are: png, pdf, svg, and ps. Options for graph file formats are: gexf.

title

an optional title for the output graph.

width

output width in pixels or NULL for default. Only useful for export to image file formats png, pdf, svg, and ps.

height

output height in pixels or NULL for default. Only useful for export to image file formats png, pdf, svg, and ps.

Examples

# Create a simple graph graph <- create_graph() %>% add_path( n = 5, edge_aes = edge_aes( arrowhead = c( "normal", "vee", "tee", "dot"), color = c( "red", "blue", "orange", "purple"))) # Create a PDF file for # the graph (`graph.pdf`) graph %>% export_graph( file_name = "graph.pdf", title = "Simple Graph")
#> Error: To use this function to produce an image file, please install the `DiagrammeRsvg` package using `devtools::install_github('rich-iannone/DiagrammeRsvg')
# Create a PNG file for # the graph (`mypng.png`) graph %>% export_graph( file_name = "mypng.png", file_type = "PNG")
#> Error: To use this function to produce an image file, please install the `DiagrammeRsvg` package using `devtools::install_github('rich-iannone/DiagrammeRsvg')