facet_panel_dimensions: Extract the panel dimensions in a faceted ggplot

facet_panel_dimensionsR Documentation

Extract the panel dimensions in a faceted ggplot

Description

This function extracts the number if rows and columns of the panel in a faceted ggplot. It can be used to calculate the width and height of a shiny::renderPlot()

Usage

facet_panel_dimensions(p)

Arguments

p

A ggplot2 object

Details

Some details here :)

Value

A named list of the number of $rows and $cols

Examples

library(ggplot2)
p1 <- ggplot(mtcars, aes(mpg, wt)) + facet_wrap(~ gear )
facet_panel_dimensions(p1)
p2 <- ggplot(mtcars, aes(mpg, wt)) + facet_grid(cyl ~ gear )
facet_panel_dimensions(p2)

lefkiospaikousis/ClusterAnalysis documentation built on July 18, 2022, 1:55 p.m.