
Interactive 2-demensional contour plots
Source:R/ggiraph-documentation-with-examples.R
gf_contour_interactive.RdCreates an interactive plot using ggiraph. These functions extend
gf_contour() and
gf_contour_filled()
with interactive features like tooltips and clickable elements.
Arguments
- object
When chaining, this holds an object produced in the earlier portions of the chain. Most users can safely ignore this argument.
- gformula
A formula with shape
y ~ x. Faceting can be achieved by including|in the formula.- data
The data to be displayed in this layer.
- tooltip
A formula specifying a variable for tooltips, or a character vector.
- data_id
A formula or character vector specifying data identifiers for interactive selection.
- ...
Additional arguments passed to the underlying geom.
- alpha, color, size, shape, fill, group, stroke
Aesthetics passed to the geom.
- xlab, ylab, title, subtitle, caption
Labels for the plot.
- show.legend
Logical. Should this layer be included in the legends?
- show.help
Logical. If
TRUE, display some minimal help.- inherit
Logical. If
TRUE, inherit aesthetics from previous layers.- environment
An environment in which to evaluate the formula.
Value
A gg object that can be displayed with gf_girafe().
Examples
faithfuld |>
gf_contour_interactive(
density ~ waiting + eruptions,
color = ~ after_stat(level),
tooltip = ~ after_stat(paste0("density: ", level)),
data_id = ~ after_stat(level),
hover_css = "stroke: red;",
hover_nearest = TRUE,
bins = 10, show.legend = FALSE) |>
gf_girafe()
faithfuld |>
gf_contour_filled_interactive(
density ~ waiting + eruptions,
fill = ~ after_stat(level),
tooltip = ~ after_stat(paste0("density: ", level)),
data_id = ~ after_stat(level),
hover_css = "fill: red; opacity: 0.5",
hover_nearest = TRUE,
bins = 10, show.legend = FALSE) |>
gf_girafe()