knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.width = 7, fig.height = 5 )
The ggPedigreeInteractive()
function extends the static pedigree plots generated by ggPedigree()
into fully interactive Plotly
widgets. This allows users to explore pedigree data in a more dynamic way, with features such as hover text, zooming, and panning.
This vignette walks through:
- Basic usage of ggPedigreeInteractive()
- Customizing the interactive plot
- Adding tooltips for additional information
# Load required packages library(BGmisc) # ships the sample 'potter' pedigree library(ggplot2) # used internally by ggPedigree* library(viridis) # viridis for color palettes library(plotly) # conversion layer for interactivity library(ggpedigree) # the package itself
The package includes a small toy pedigree for the Harry Potter universe:
# Load the example data data("potter") # Display the first few rows of the dataset head(potter)
A minimal call is just:
ggPedigreeInteractive(potter)
...but you will usually want to identify the core primary‑key columns in advance:
plt <- ggPedigreeInteractive( potter, famID = "famID", personID = "personID", momID = "momID", dadID = "dadID" ) |> plotly::hide_legend()
plt
# reduce file size for CRAN if (interactive()) { # If running interactively, use plotly::partial_bundle # to reduce file size for CRAN plotly::partial_bundle(plt) } else { plotly::partial_bundle(plt, local = TRUE) }
The above code generates an interactive pedigree plot of the Potter family tree. You can zoom in, pan around, and hover over nodes to see more information. You can do much more with the ggPedigreeInteractive()
function, including customizing labels, colors, and tooltips. To experience the full list of options, refer to the online article.
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.