ape (version 3.0-9)

plot.phylo: Plot Phylogenies

Description

These functions plot phylogenetic trees on the current graphical device.

Usage

## S3 method for class 'phylo':
plot(x, type = "phylogram", use.edge.length = TRUE,
    node.pos = NULL, show.tip.label = TRUE, show.node.label = FALSE,
    edge.color = "black", edge.width = 1, edge.lty = 1, font = 3,
    cex = par("cex"), adj = NULL, srt = 0, no.margin = FALSE,
    root.edge = FALSE, label.offset = 0, underscore = FALSE,
    x.lim = NULL, y.lim = NULL, direction = "rightwards",
    lab4ut = "horizontal", tip.color = "black", plot = TRUE,
    rotate.tree = 0, open.angle = 0, ...)
## S3 method for class 'multiPhylo':
plot(x, layout = 1, ...)

Arguments

Value

plot.phylo returns invisibly a list with the following components which values are those used for the current plot:typeuse.edge.lengthnode.posshow.tip.labelshow.node.labelfontcexadjsrtno.marginlabel.offsetx.limy.limdirectiontip.colorNtipNnode

Details

If x is a list of trees (i.e., an object of class "multiPhylo"), then any further argument may be passed with ... and could be any one of those listed above for a single tree.

The font format of the labels of the nodes and the tips is the same.

If no.margin = TRUE, the margins are set to zero and are not restored after plotting the tree, so that the user can access the coordinates system of the plot.

The option `node.pos' allows the user to alter the vertical position (i.e. ordinates) of the nodes. If node.pos = 1, then the ordinate of a node is the mean of the ordinates of its direct descendants (nodes and/or tips). If node.pos = 2, then the ordinate of a node is the mean of the ordinates of all the tips of which it is the ancestor. If node.pos = NULL (the default), then its value is determined with respect to other options: if type = "phylogram" then `node.pos = 1'; if type = "cladogram" and use.edge.length = FALSE then `node.pos = 2'; if type = "cladogram" and use.edge.length = TRUE then `node.pos = 1'. Remember that in this last situation, the branch lengths make sense when projected on the x-axis.

If adj is not specified, then the value is determined with respect to direction: if direction = "leftwards" then adj = 1 (0 otherwise).

If the arguments x.lim and y.lim are not specified by the user, they are determined roughly by the function. This may not always give a nice result: the user may check these values with the (invisibly) returned list (see ``Value:'').

If you resize manually the graphical device (windows or X11) you may need to replot the tree.

See Also

read.tree, trex, kronoviz, add.scale.bar, axisPhylo, nodelabels, edges, plot for the basic plotting function in R

Examples

Run this code
### An extract from Sibley and Ahlquist (1990)
cat("(((Strix_aluco:4.2,Asio_otus:4.2):3.1,",
   "Athene_noctua:7.3):6.3,Tyto_alba:13.5);",
   file = "ex.tre", sep = "")
tree.owls <- read.tree("ex.tre")
plot(tree.owls)
unlink("ex.tre") # delete the file "ex.tre"

### Show the types of trees.
layout(matrix(1:6, 3, 2))
plot(tree.owls, main = "With branch lengths")
plot(tree.owls, type = "c")
plot(tree.owls, type = "u")
plot(tree.owls, use.edge.length = FALSE, main = "Without branch lengths")
plot(tree.owls, type = "c", use.edge.length = FALSE)
plot(tree.owls, type = "u", use.edge.length = FALSE)
layout(matrix(1))

data(bird.orders)
### using random colours and thickness
plot(bird.orders,
     edge.color = sample(colors(), length(bird.orders$edge)/2),
     edge.width = sample(1:10, length(bird.orders$edge)/2, replace = TRUE))
title("Random colours and branch thickness")
### rainbow colouring...
X <- c("red", "orange", "yellow", "green", "blue", "purple")
plot(bird.orders,
     edge.color = sample(X, length(bird.orders$edge)/2, replace = TRUE),
     edge.width = sample(1:10, length(bird.orders$edge)/2, replace = TRUE))
title("Rainbow colouring")
plot(bird.orders, type = "c", use.edge.length = FALSE,
     edge.color = sample(X, length(bird.orders$edge)/2, replace = TRUE),
     edge.width = rep(5, length(bird.orders$edge)/2))
segments(rep(0, 6), 6.5:1.5, rep(2, 6), 6.5:1.5, lwd = 5, col = X)
text(rep(2.5, 6), 6.5:1.5, paste(X, "..."), adj = 0)
title("Character mapping...")
plot(bird.orders, "u", font = 1, cex = 0.75)
data(bird.families)
plot(bird.families, "u", lab4ut = "axial", font = 1, cex = 0.5)
plot(bird.families, "r", font = 1, cex = 0.5)
### cladogram with oblique tip labels
plot(bird.orders, "c", FALSE, direction = "u", srt = -40, x.lim = 25.5)
### facing trees with different informations...
tr <- bird.orders
tr$tip.label <- rep("", 23)
layout(matrix(1:2, 1, 2), c(5, 4))
plot(bird.orders, "c", FALSE, adj = 0.5, no.margin = TRUE, label.offset = 0.8,
     edge.color = sample(X, length(bird.orders$edge)/2, replace = TRUE),
     edge.width = rep(5, length(bird.orders$edge)/2))
text(7.5, 23, "Facing trees with
different informations", font = 2)
plot(tr, "p", direction = "l", no.margin = TRUE,
     edge.width = sample(1:10, length(bird.orders$edge)/2, replace = TRUE))
### Recycling of arguments gives a lot of possibilities
### for tip labels:
plot(bird.orders, tip.col = c(rep("red", 5), rep("blue", 18)),
     font = c(rep(3, 5), rep(2, 17), 1))
plot(bird.orders, tip.col = c("blue", "green"),
     cex = 23:1/23 + .3, font = 1:3)
co <- c(rep("blue", 9), rep("green", 35))
plot(bird.orders, "f", edge.col = co)
plot(bird.orders, edge.col = co)
layout(1)

Run the code above in your browser using DataCamp Workspace