Skip to contents

Adds one leader segment per extremum from the extremum vertex to an outward label anchor. This helps keep extrema labels away from nearby endpoint labels.

Usage

label.extrema.leaders.3d(
  graph.3d,
  extrema.df,
  extrema.type = c("both", "maxima", "minima"),
  offset = c(0, 0, 0),
  radial.frac = 0.09,
  z.frac = 0.01,
  avoid.vertices = integer(0),
  avoid.weight = 1.1,
  with.labels = TRUE,
  lab.cex = 1.5,
  lab.adj = c(0, 0),
  separate.colors = TRUE,
  col.max = "red",
  col.min = "blue",
  col = "black",
  line.lwd = 2,
  line.alpha = 1,
  ...
)

Arguments

graph.3d

A matrix with 3 columns representing 3D coordinates.

extrema.df

Data frame with columns vertex, label, and either is_max (0/1) or type ("min"/"max").

extrema.type

Character string specifying which extrema to plot: "both" (default), "maxima", or "minima".

offset

Numeric vector of length 3 added to each label anchor location. Default c(0, 0, 0).

radial.frac

Numeric scalar giving outward leader length as a fraction of the mean coordinate extent. Default 0.09.

z.frac

Numeric scalar giving additional z-shift as a fraction of the mean coordinate extent. Default 0.01.

avoid.vertices

Optional vertex ids used to repel label anchors away from nearby vertices (for example, endpoint labels).

avoid.weight

Repulsion weight for avoid.vertices. Default 1.1.

with.labels

Logical. Whether to draw text labels. Default TRUE.

lab.cex

Character expansion factor for labels. Default 1.5.

lab.adj

Adjustment parameter for label positioning. Default c(0, 0).

separate.colors

Logical. If TRUE and extrema.type="both", plot maxima and minima with different colors. Default TRUE.

col.max

Color for maxima. Default "red".

col.min

Color for minima. Default "blue".

col

Color for all extrema when separate.colors=FALSE. Default "black".

line.lwd

Leader segment width. Default 2.

line.alpha

Leader segment alpha between 0 and 1. Default 1.

...

Additional arguments passed to rgl::segments3d().

Value

Invisibly returns NULL.

Examples

if (FALSE) { # \dontrun{
# Leader labels for both maxima and minima
label.extrema.leaders.3d(graph.3d, extrema.df)

# Push labels farther out and slightly up in z
label.extrema.leaders.3d(
  graph.3d,
  extrema.df,
  radial.frac = 0.12,
  z.frac = 0.02
)

# Repel labels away from endpoint vertices
label.extrema.leaders.3d(
  graph.3d,
  extrema.df,
  avoid.vertices = as.integer(names(end.labels))
)
} # }