make_interactive {topolow} | R Documentation |
Create Interactive Plot
Description
Converts a static ggplot visualization to an interactive plotly visualization with customizable tooltips and interactive features.
Usage
make_interactive(plot, tooltip_vars = NULL)
Arguments
plot |
ggplot object to convert |
tooltip_vars |
Vector of variable names to include in tooltips |
Details
The function enhances static plots by adding:
Hover tooltips with data values
Zoom capabilities
Pan capabilities
Click interactions
Double-click to reset
If tooltip_vars is NULL, the function attempts to automatically determine relevant variables from the plot's mapping.
Value
A plotly
object with interactive features.
Examples
if (interactive() && requireNamespace("plotly", quietly = TRUE)) {
# Create sample data and plot
data <- data.frame(
V1 = rnorm(100), V2 = rnorm(100), name=1:100,
antigen = rep(c(0,1), 50), antiserum = rep(c(1,0), 50),
year = rep(2000:2009, each=10), cluster = rep(1:5, each=20)
)
# Create temporal plot
p1 <- plot_temporal_mapping(data, ndim=2)
# Make interactive with default tooltips
p1_interactive <- make_interactive(p1)
# Create cluster plot with custom tooltips
p2 <- plot_cluster_mapping(data, ndim=2)
p2_interactive <- make_interactive(p2,
tooltip_vars = c("cluster", "year", "antigen")
)
}
[Package topolow version 1.0.0 Index]