Skip to contents

Creates a Quarto tabset from a named list of ggplot2 objects, typically generated by makeme() with crowd parameter. Each plot becomes a tab with automatic height calculation and optional download links.

Usage

crowd_plots_as_tabset(
  plot_list,
  plot_type = c("cat_plot_html", "int_plot_html", "auto"),
  save = FALSE,
  fig_height = NULL,
  fig_height_int_default = 6
)

Arguments

plot_list

A named list of ggplot2 objects. Names become tab labels. Typically created with makeme(crowd = c("target", "others")).

plot_type

Character. Type of plots in the list. One of:

  • "cat_plot_html" (default): Categorical horizontal bar charts

  • "int_plot_html": Interval plots (violin/box plots)

  • "auto": Auto-detect from first non-NULL plot's data structure

save

Logical. If TRUE (default), generates download links for plot data and images via get_fig_title_suffix_from_ggplot().

fig_height

Numeric or NULL. Manual figure height override in inches. If NULL (default), height is calculated automatically based on plot_type.

fig_height_int_default

Numeric. Default height for interval plots when auto-calculation is not available (default: 6 inches).

Value

Invisibly returns NULL. The function's purpose is its side effect of printing Quarto markdown that creates a tabset.

Details

This function is designed to be called within a Quarto document code chunk. It generates markdown that creates a tabset where each non-NULL plot in plot_list appears as a separate tab.

Height Calculation:

  • For "cat_plot_html": Uses fig_height_h_barchart2() which accounts for number of variables, categories, and label lengths

  • For "int_plot_html": Uses fig_height_int_default (simpler plots need less sophisticated calculation)

  • For "auto": Detects type by checking for .category column (categorical) vs numeric statistics columns (interval)

Requirements:

  • Must be run within knitr/Quarto context

  • Plots should be created with makeme()

  • Plot list should have meaningful names for tab labels

See also

Examples

if (FALSE) { # \dontrun{
# In a Quarto document
plots <- makeme(
  data = ex_survey,
  dep = b_1:b_3,
  crowd = c("target", "others"),
  mesos_var = "f_uni",
  mesos_group = "Uni of A"
)

# Create tabset with auto-detection
crowd_plots_as_tabset(plots)

# Create tabset for interval plots
int_plots <- makeme(
  data = ex_survey,
  dep = c_1:c_2,
  indep = x1_sex,
  type = "int_plot_html",
  crowd = c("target", "others"),
  mesos_var = "f_uni",
  mesos_group = "Uni of A"
)
crowd_plots_as_tabset(int_plots, plot_type = "int_plot_html")

# Without download links
crowd_plots_as_tabset(plots, save = FALSE)

# With manual height override
crowd_plots_as_tabset(plots, fig_height = 8)
} # }