Skip to contents

The 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.frame with columns id and text mapping 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 (default 0.3).

label_terminal

Show the final group id (c1gN) to the right of each final-year node (default TRUE).

label_size

Font size (px) of the final-node labels (default 12).

title

Plot title (default "Cumulative network groups"); NULL for none.

Value

A plotly htmlwidget.

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 the labels_text description); hovering any other node shows its raw id (yYYYYcXgN).

  • Edges are a single faint layer (edge_alpha) and are excluded from hover. With label_terminal = TRUE the 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().

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)
} # }