
Interactive trajectory DAG (plotly): hover a node for its trajectory
Source:R/plot_trajectory_dag_interactive.R
plot_trajectory_dag_interactive.RdThe plotly twin of plot_trajectory_dag(). Nodes are laid out by the same
year-aware Sugiyama layout, sized by paper count, and coloured by the final
group their lineage reaches. Dormant lineages that never reach the final year
are drawn grey. There is no legend: hovering a final-year node shows its group
id and labels_text description (c1gN: description), and hovering any other
(intermediate or dormant) node shows its raw id (e.g. y2021c1g2). When
label_terminal is TRUE, the
final group id (c1gN) is also printed to the right of each final-year node.
Returns a plotly htmlwidget.
Usage
plot_trajectory_dag_interactive(
dag,
labels_text = NULL,
marker_range = c(4, 14),
edge_alpha = 0.3,
label_terminal = TRUE,
label_size = 12,
title = "Cumulative network groups"
)Arguments
- dag
A
sniff_trajectory_dag()object.- labels_text
Optional
data.framewith columnsidandtextmapping final group ids to descriptions, shown after the group id when hovering a final-year node (c1gN: description);NULL(default) falls back to the bare group id.- marker_range
Min/max marker size in pixels; paper count is scaled into this range (default
c(4, 14)).- edge_alpha
Edge opacity,
0-1(default0.3).- label_terminal
Show the final group id (
c1gN) to the right of each final-year node (defaultTRUE).- label_size
Font size (px) of the final-node labels (default
12).- title
Plot title (default
"Cumulative network groups");NULLfor none.
Details
The interactive twin of plot_trajectory_dag(), built with plotly:
The x-axis is the publication year (Sugiyama layout); the y-axis has no intrinsic meaning.
Node colour is the trajectory basin (the final group reached); dormant lineages that never reach the final year are grey. Node size scales with paper count over
marker_range.There is no legend. Hovering a final-year node shows
c1gN: description(its group id plus thelabels_textdescription); hovering any other node shows its raw id (yYYYYcXgN).Edges are a single faint layer (
edge_alpha) and are excluded from hover. Withlabel_terminal = TRUEthe final group ids (c1gN) are printed in a de-overlapped column to the right, each joined to its node by a leader line.
The widget renders in the RStudio Viewer, embeds in Quarto/Shiny, or saves to a
standalone file with htmlwidgets::saveWidget().
See also
plot_trajectory_dag(), plot_groups_per_year()
Other visualization:
plot_groups_influence_matrix(),
plot_groups_influence_network(),
plot_groups_lineage_2d(),
plot_groups_lineage_3d(),
plot_groups_map(),
plot_groups_map_animation(),
plot_groups_map_interactive(),
plot_groups_per_year(),
plot_trajectory_confluence(),
plot_trajectory_confluence_interactive(),
plot_trajectory_confluence_matrix(),
plot_trajectory_dag(),
plot_trajectory_dispersion(),
plot_trajectory_dynamics(),
plot_trajectory_dynamics_interactive(),
plot_trajectory_formation(),
plot_trajectory_lines_2d(),
plot_trajectory_lines_3d()
Examples
if (FALSE) { # \dontrun{
# docs_per_group comes from sniff_groups_lineage()
dag <- sniff_trajectory_dag(docs_per_group)
plot_trajectory_dag_interactive(dag)
# hover the final nodes for descriptions; fainter edges
descr <- data.frame(id = c("c1g1", "c1g2"), text = c("Topic A", "Topic B"))
p <- plot_trajectory_dag_interactive(dag, labels_text = descr, edge_alpha = 0.2)
# htmlwidgets::saveWidget(p, "trajectory_dag.html", selfcontained = TRUE)
} # }