For a plot drawn with a fixed panel size (the ggplot_dag() default),
returns the full plot's size, including any legend or title added with
ggplot2::labs(); a legend taller than the graph makes the plot taller,
so it isn't cut off (with a few percent to spare, as devices measure text
slightly differently). Otherwise, returns the view box size at 1 px per data
unit (96 dpi), read from the coord_fixed() limits that dag_layers()
sets. Useful for sizing figures, e.g. knitr's fig.width/fig.height.
Arguments
- plot
A plot from
ggplot_dag()ortar_ggplot().
Examples
dag <- as_dag(data.frame(from = c("a", "a", "b"), to = c("b", "c", "c")))
dag_size(ggplot_dag(dag))
#> width height
#> 0.750 0.625
dag_size(ggplot_dag(dag, node_color = "name")) # wider: includes the legend
#> width height
#> 1.3380034 0.9723921