create.distance.plot: Create Distance Plot

View source: R/graph_edit_distance.R

create.distance.plotR Documentation

Create Distance Plot

Description

Creates a plot of edit distances with optional smoothing or regression results.

Usage

create.distance.plot(
  x,
  y,
  smooth = TRUE,
  smooth.method = "loess",
  mark.x = NULL,
  xlab = "Number of Nearest Neighbors (k)",
  ylab = "Edit Distance",
  main = NULL,
  width = 6,
  height = 6,
  ...
)

Arguments

x

Numeric vector of x-axis values (e.g., k values).

y

Numeric vector of y-axis values (e.g., edit distances).

smooth

Logical indicating whether to add a smoothing line (default: TRUE).

smooth.method

Character string specifying the smoothing method. Options include "loess" (default), "lm", "glm", "gam".

mark.x

Optional numeric value(s) to mark with vertical lines.

xlab

Character string for x-axis label (default: "Number of Nearest Neighbors (k)").

ylab

Character string for y-axis label (default: "Edit Distance").

main

Character string for plot title (default: NULL, no title).

width

Numeric value for plot width in inches (default: 6).

height

Numeric value for plot height in inches (default: 6).

...

Additional arguments passed to plot().

Details

The function creates a scatter plot with optional smoothing line. If mark.x is provided, vertical dashed lines are added at those x-values.

Value

Returns NULL invisibly after drawing the plot.

Examples

k.vals <- c(5, 10, 15, 20)
distances <- c(2.2, 1.4, 1.1, 1.3)
create.distance.plot(k.vals, distances, smooth = FALSE)

min.k <- k.vals[which.min(distances)]
create.distance.plot(k.vals, distances, mark.x = min.k,
                     smooth = FALSE,
                     main = "Edit Distance vs k")

dgraphs documentation built on Aug. 21, 2026, 1:08 a.m.