mvlabs: Move Text Labels Interactively

View source: R/plots.R

mvlabsR Documentation

Move Text Labels Interactively

Description

There is no easy way to move point labels around interactively on an a plot in R. This function allows a point and click way to select (using identify) and move (using locator) points by modifying the underlying dataframe.

Usage

mvlabs(df, n=nrow(df), x='x', y='y', l='lab', cols=colors()[grep("dark",colors())], ...)

Arguments

df

A dataframe with x and y coordinates and text labels.

n

the number of points you wish to move.

x

the column name of the x axis coordinates.

y

the column name of the y axis coordinates.

l

the column name of the point labels.

cols

the color vector to iterate through while assigning new positions.

...

other parameters passed on to text.

See Also

locator,identify,labsegs

Examples

  x <- rnorm(20); y <- rnorm(20)
  df <- data.frame(x,y, lab=as.character(letters[1:20]))
  plot(df$x, df$y, pch=''); text(df$x, df$y, df$lab)
  ## df <- mvlabs(df, 'x','y','lab', n=3)  
  plot(df$x, df$y, pch=''); text(df$x, df$y, df$lab)

caroline documentation built on July 15, 2026, 9:06 a.m.