
Plot 2D trajectories as variable-width lines
Source:R/plot_group_trajectories_lines_2d.R
plot_group_trajectories_lines_2d.RdCreates a 2D line plot showing research trajectories over time, with highlighted trajectories displayed as variable-width lines and optional background trajectories shown in lowlight style. Edge widths grow along each highlighted trajectory based on cumulative paper counts, and labels are placed at trajectory endpoints.
Usage
plot_group_trajectories_lines_2d(
traj_data,
traj_filtered,
title = "Main trajectories",
width_range = c(0.8, 6),
use_raw_papers = FALSE,
label_nudge_x = 0.3,
label_size = 4,
show_only_highlighted = FALSE,
lowlight_width = 0.9,
lowlight_alpha = 0.22,
lowlight_color = "#9AA5B1"
)Arguments
- traj_data
List containing trajectory data generated by
detect_main_trajectories()with components:graph: igraph object containing nodes and edges across yearstrajectories: tibble of all candidate trajectories (traj_id + nodes list)
- traj_filtered
Filtered trajectories tibble from
filter_trajectories()containing the subset to emphasize. Must contain columns:traj_id: trajectory identifiersnodes: list of character vectors (ordered by time or orderable)
- title
Plot title (default: "Main trajectories")
- width_range
Range for edge widths of highlighted trajectories (default: c(0.8, 6.0)). Width at each segment is scaled by cumulative paper count up to the next node.
- use_raw_papers
Whether to use raw paper counts for width scaling (default: FALSE). If TRUE, uses raw
quantity_papers; if FALSE, uses weighted size:quantity_papers * prop_tracked_intra_group.- label_nudge_x
Horizontal nudge for trajectory end labels to prevent overlap with nodes (default: 0.30)
- label_size
Text size for trajectory end labels (default: 4)
- show_only_highlighted
Whether to show only highlighted trajectories (default: FALSE). If TRUE, hides all non-highlighted trajectory lines; if FALSE, draws lowlight background.
- lowlight_width
Line width for lowlight (background) edges (default: 0.9)
- lowlight_alpha
Transparency for lowlight edges (default: 0.22; smaller values = more transparent)
- lowlight_color
Color for lowlight edges (default: "#9AA5B1" - neutral gray)
Details
This function visualizes research trajectories as variable-width lines:
Highlighted trajectories (
traj_filtered) are colored lines with widths proportional to cumulative paper counts (raw or weighted)Background trajectories (when
show_only_highlighted = FALSE) are shown as thin, transparent linesTrajectory labels are placed at the end of each highlighted trajectory
The x-axis represents publication years using a Sugiyama layout
The y-axis shows vertical positions from the layout (no intrinsic meaning)
Colors are assigned only to highlighted trajectories present in the plot
When traj_data$trajectories is available and show_only_highlighted = FALSE,
the lowlight layer shows only edges that belong to any trajectory but not the
highlighted set. Otherwise, it shows the entire graph minus highlighted edges.
Examples
if (FALSE) { # \dontrun{
# Detect main trajectories first
traj_data <- detect_main_trajectories(your_graph_data)
# Filter trajectories of interest
filtered_traj <- filter_trajectories(traj_data$trajectories,
min_papers = 10)
# Create the plot
plot_group_trajectories_lines_2d(
traj_data = traj_data,
traj_filtered = filtered_traj,
title = "Key Research Trajectories",
width_range = c(1, 8),
show_only_highlighted = FALSE
)
} # }