flametree_save: Save the plot

Description Usage Arguments Details Value Examples

View source: R/save.R

Description

Save the plot

Usage

1
flametree_save(plot, filename, ...)

Arguments

plot

The ggplot object

filename

The path to the file

...

Other arguments to be passed to ggsave

Details

The flametree_save() function provides a very thin wrapper around the ggsave() function from ggplot2. It reverses the order of the first two arguments: the plot argument comes before filename, in order to be more pipe-friendly. The second thing it does is inspect the plot object to determine the background colour, and ensures that colour is also used to specify the background colour for the graphics device (e.g., the bg argument to png()). The reason for doing this is that plots created using flametree_plot() typically force the coordinates to be on the same scale using coord_equal(). As a consequence, if the aspect ratio of the image differs from the aspect ratio of the ggplot there will be sections of the image that show the background colour of the graphics device rather than the background colour specified by the ggplot object. By overriding the default behaviour of ggsave(), the flametree_save() function ensures that the image has the same background colour everywhere.

Value

Invisibly returns NULL.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
## Not run: 
# typical usage
flametree_grow(trees = 5, time = 8) %>%
  flametree_plot(style = "voronoi") %>%
  flametree_save(filename = "~/Desktop/myfile.png")

# passing additional arguments to ggsave()
flametree_grow(trees = 5, time = 8) %>%
  flametree_plot(style = "voronoi") %>%
  flametree_save(
    filename = "~/Desktop/myfile.png",
    height = 8,
    width = 8
  )

## End(Not run)

flametree documentation built on Nov. 29, 2021, 9:12 a.m.