Learn R Programming

ggformula (version 2.0.0)

gf_girafe: Render interactive ggformula plots

Description

Converts a ggplot object with interactive elements into an interactive HTML widget using ggiraph. This function is a wrapper around ggiraph::girafe() tailored for ggformula interactive plots.

Usage

gf_girafe(ggobj, code, ...)

Value

An interactive HTML widget that can be displayed in RStudio Viewer, R Markdown documents, or Shiny applications.

Arguments

ggobj

A ggplot object, typically created with a gf_*_interactive() function.

code

R code to execute. This parameter is optional and rarely used in typical workflows.

...

Additional arguments passed to ggiraph::girafe(), such as width_svg, height_svg, options, etc.

Details

This function takes a ggplot object containing interactive elements (created with gf_*_interactive() functions) and renders it as an interactive plot. The resulting widget supports features like tooltips, hover effects, and clickable elements.

See Also

ggiraph::girafe(), gf_point_interactive(), and other gf_*_interactive() functions

Examples

Run this code
library(ggformula)

# Basic interactive plot
gf_point_interactive(mpg ~ wt, data = mtcars,
                    tooltip = ~ paste("Car:", rownames(mtcars))) |>
  gf_girafe()

# With custom sizing
gf_histogram_interactive(~ mpg, data = mtcars,
                        tooltip = ~ paste("Count:", after_stat(count))) |>
  gf_girafe(width_svg = 8, height_svg = 6)

Run the code above in your browser using DataLab