R/autoplot.R
autoplot.treedata.RdCreates a ggplot2 visualization of continuous phylogeographic data from
BEAST analyses. For simple quick plots, this function provides sensible
defaults. For custom visualizations, use build_phylogeo() with the
individual geom functions (geom_phylo_branches(), geom_phylo_hpd(),
geom_phylo_nodes()).
autoplot.treedata(
object,
most_recent_sample = NULL,
lat = "location1",
lon = "location2",
show_map = TRUE,
show_dispersion_legend = TRUE,
smooth = TRUE,
stream = FALSE,
curvature = -0.25,
highlight_tips = NULL,
highlight_color = "red",
tip_size = 3.5,
node_size = 3,
tip_stroke = 1,
date_format = "%Y",
animate = FALSE,
nframes = 100,
fps = 10,
end_pause = 20,
renderer = NULL,
debug = getOption("ggphylogeo.debug", FALSE),
height_branches = "height_mean",
height_hpd = "height_median",
level = "0.80",
digits = 2,
map_pad = 1,
map_name = "world",
map_fill = "white",
map_colour = "gray50",
arrow = NULL,
...
)A treedata object with phylogeographic annotations from
treeio::read.beast()
Date, numeric year (e.g. 2019), or "YYYY-MM-DD" string for calibrating ages to real dates. If NULL, ages remain as numeric heights.
Name of latitude coordinate column (default: "location1")
Name of longitude coordinate column (default: "location2")
Logical; overlay world map background (default TRUE)
Logical; show legend explaining branch curvature direction (default TRUE)
Logical; smooth HPD polygons for visual appeal (default TRUE)
Logical; use stream-style branch plotting with fade effect (default FALSE)
Curvature of branch curves (default -0.25). Positive values curve left, negative curve right.
Character vector of tip labels to highlight with special styling
Color for highlighted tips (default "red")
Size of tip nodes (default 3.5)
Size of internal nodes (default 3)
Stroke width for tip nodes (default: 1)
Format string for date axis labels (default "%Y")
Logical; create animated plot showing temporal progression (default FALSE). Requires gganimate and gifski packages.
Number of frames for animation (default 100)
Frames per second for animation (default 10)
Frames to pause at end of animation (default 20)
gganimate renderer function. Default uses gifski if available.
Logical; emit debug messages (default FALSE)
Column name for branch ages (default: "height_mean")
Column name for HPD ages (default: "height_median")
HPD level to display (default: "0.80" for 80% HPD)
Decimal places for coordinate rounding (default: 2)
Padding in degrees around data extent (default: 1)
Map database name from maps package (default: "world")
Fill color for map polygons (default: "white")
Outline color for map polygons (default: "gray50")
Arrow specification for branches (default: NULL)
Additional arguments passed to geoms
A ggplot2 object (if animate=FALSE) or gganim object (if animate=TRUE)
if (FALSE) { # \dontrun{
data(wnv_tree)
# Basic plot
autoplot(wnv_tree, most_recent_sample = "2007-07-01")
# With highlighting
autoplot(wnv_tree,
most_recent_sample = "2007-07-01",
highlight_tips = c("WN99-flamingo383"))
# Animation (requires gganimate)
anim <- autoplot(wnv_tree,
most_recent_sample = "2007-07-01",
animate = TRUE, nframes = 50)
} # }