replot: Edit the Layout of a Haplotype Network

View source: R/haplotype.R

replotR Documentation

Edit the Layout of a Haplotype Network


This function makes possible to change the layout of a haplotype network interactively or with specified coordinates.


replot(xy = NULL, col.identifier = "purple", ...)



an optional list with vectors names x and y (or xx and yy) giving the coordinates of the nodes.


the colour used to identify the node to be moved.


further arguments passed to plot.


This function can be used in two ways. By default (i.e., replot()), the user can edit a plotted haplotype network by clicking with the mouse on the graphical window: a message is printed asking to click once close to the node to move and then clicking again where this node should be placed (careful: two separate single clicks). Editing is stopped with a right click.

The second possible use is to specify the new coordinates of the nodes with the argument xy, typically, from a previous call to replot (see examples).

Since pegas 1.0, these coordinates can be used directly in plot.haploNet making possible to combine networks with other graphics (which not possible with replot because the network is replotted).


a named list with two numeric vertors (x and y).


For users of RStudio: the function does not work within this application. It seems the best is to run R from a shell (or maybe opening a new graphical device with X11).


Emmanuel Paradis

See Also

haploNet, haploFreq


## a non-interactive example:
layout(matrix(1:2, 1))
plot(ntz, labels = TRUE)
## it is possible plot this network with no line-crossing
## with these coordinates:
xy <- list(x = c(3.2, -2.6, -6.6, -7.2, 0, 3.5, 2.6, -2.9, -0.3, 3.4, -3.4),
           y = c(3.4, 4.4, 1.3, -3.9, -5.5, -10.9, 0.1, -0.8, -2.3,  -7.9, -8.1))
replot(ntz, xy = xy) # or plot(ntz, xy = xy, labels = TRUE)

## an interactive example:
## Not run: 
net <- haploNet(haplotype(woodmouse))
o <- replot() # interactive
## click to rearrange the network at will...
## then do a different plot using the same coordinates:
plot(net, bg = "red", labels = FALSE, show.mutation = 2)
replot(o) # not interactive

## End(Not run)

pegas documentation built on May 29, 2024, 2:27 a.m.