Consider a faceted ggplot
plotdf <- data.frame(x = 1:21, y = 3*(1:21)+4, z = c(rep(1,3), rep(2,3), rep(3,3), rep(4
gg_facet_nrow <- function(p){ assertive.types::assert_is_any_of(p, 'ggplot') p %>% ggplot2::ggplot_build() %>% magrittr::extract2('layout') %>% magrittr::extract2('panel_layout') %>% magrittr::extract2('ROW') %>% unique() %>% length() } gg_facet_nrow(p)