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.
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 aswidth_svg,height_svg,options, etc.
Value
An interactive HTML widget that can be displayed in RStudio Viewer, R Markdown documents, or Shiny applications.
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
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)
#> `stat_bin()` using `bins = 30`. Pick better value `binwidth`.
