grob_dimensions

Convenient Access to grob Dimensions

Convenience functions extracting dimensions from grob objects.

Usage
figure_width(grob, unit_to = "mm")
figure_height(grob, unit_to = "mm")
Arguments
grob

A grob object for which dimensions are to be retrieved.

unit_to

A single character string representing a valid grid-unit.

Value

Single numeric objects are returned.

References

Graumann, J., and Cotton, R.J. (2018). multipanelfigure: Simple Assembly of Multiple Plots and Images into a Compound Figure. Journal of Statistical Software 84. doi: 10.18637/jss.v084.c03

See Also

multi_panel_figure, save_multi_panel_figure

Aliases
  • grob_dimensions
  • figure_width
  • simplegrobheight
  • simplegrobwidth
  • simple_grob_height
  • simple_grob_width
  • figure_height
Examples
# NOT RUN {
# Get dimensions of a grid grob
a_circle <- grid::circleGrob(x = 15, y = 30, r = 15, default.unit = "mm")
figure_height(a_circle)
figure_width(a_circle)

# Use the unit_to arg to convert units
figure_height(a_circle, unit_to = "in")
figure_width(a_circle, unit_to = "cm")

# Get dimensions of a multi-panel figure
figure <- multi_panel_figure(width = 55, height = 55, rows = 2, columns = 2)
figure_height(figure)
figure_width(figure)

# ggsave defaults to measuring dimensions in inches
width <- figure_width(figure, unit_to = "in")
height <- figure_height(figure, unit_to = "in")
tmp_file <- tempfile(fileext = ".png")
ggplot2::ggsave(
  tmp_file, gtable::gtable_show_layout(figure),
  width = width, height = height
)
# }
# NOT RUN {
 # Not testing due to use of external software
utils::browseURL(tmp_file)
# }
Documentation reproduced from package multipanelfigure, version 2.1.2, License: GPL (>= 3)

Community examples

Looks like there are no examples yet.