geom_tiplab: geom_tiplab

View source: R/geom_tiplab.R

geom_tiplabR Documentation

geom_tiplab

Description

add tip label layer for a tree

Usage

geom_tiplab(
  mapping = NULL,
  hjust = 0,
  align = FALSE,
  linetype = "dotted",
  linesize = 0.5,
  geom = "text",
  offset = 0,
  as_ylab = FALSE,
  ...
)

Arguments

mapping

aes mapping

hjust

horizontal adjustment, defaults to 0

align

if TRUE, align all tip labels to the longest tip by adding padding characters to the left side of tip labels, defaults to "FALSE" with a line connecting each tip and its corresponding label, defaults to "FALSE"

linetype

set linetype of the line if align = TRUE, defaults to "dotted"

linesize

set line width if align = TRUE, defaults to 0.5

geom

one of 'text', 'label', 'shadowtext', 'image' and 'phylopic'

offset

tiplab offset, horizontal adjustment to nudge tip labels, defaults to 0

as_ylab

display tip labels as y-axis label, only works for rectangular and dendrogram layouts, defaults to "FALSE"

...

additional parameter

additional parameters can refer the following parameters.

The following parameters for geom="text".

  • size control the size of tip labels, defaults to 3.88.

  • colour control the colour of tip labels, defaults to "black".

  • angle control the angle of tip labels, defaults to 0.

  • vjust A numeric vector specifying vertical justification, defaults to 0.5.

  • alpha the transparency of text, defaults to NA.

  • family the family of text, defaults to 'sans'.

  • fontface the font face of text, defaults to 1 (plain), others are 2 (bold), 3 (italic), 4 (bold.italic).

  • lineheight The height of a line as a multiple of the size of text, defaults to 1.2 .

  • nudge_x horizontal adjustment to nudge labels, defaults to 0.

  • nudge_y vertical adjustment to nudge labels, defaults to 0.

  • check.overlap if TRUE, text that overlaps previous text in the same layer will not be plotted.

  • parse if TRUE, the labels will be parsed into expressions, if it is 'emoji', the labels will be parsed into emojifont.

The following parameters for geom="label".

  • size the size of tip labels, defaults to 3.88.

  • colour the colour of tip labels, defaults to "black".

  • fill the colour of rectangular box of labels, defaults to "white".

  • vjust numeric vector specifying vertical justification, defaults to 0.5.

  • alpha the transparency of labels, defaults to NA.

  • family the family of text, defaults to 'sans'.

  • fontface the font face of text, defaults to 1 (plain), others are 2 (bold), 3 (italic), 4 (bold.italic).

  • lineheight The height of a line as a multiple of the size of text, defaults to 1.2.

  • nudge_x horizontal adjustment to nudge labels, defaults to 0.

  • nudge_y vertical adjustment, defaults to 0.

  • check.overlap if TRUE, text that overlaps previous text in the same layer will not be plotted.

  • parse if TRUE, the labels will be parsed into expressions, if it is 'emoji', the labels will be parsed into emojifont.

  • label.padding Amount of padding around label, defaults to 'unit(0.25, "lines")'.

  • label.r Radius of rounded corners, defaults to 'unit(0.15, "lines")'.

  • label.size Size of label border, in mm, defaults to 0.25.

The following parameters for geom="shadowtext", some parameters are like to geom="text".

  • bg.colour the background colour of text, defaults to "black".

  • bg.r the width of background of text, defaults to 0.1 .

The following parameters for geom="image" or geom="phylopic".

  • image the image file path for geom='image', but when geom='phylopic', it should be the uid of phylopic databases.

  • size the image size, defaults to 0.05.

  • colour the color of image, defaults to NULL.

  • alpha the transparency of image, defaults to 0.8.

The following parameters for the line when align = TRUE.

  • colour the colour of line, defaults to 'black'.

  • alpha the transparency of line, defaults to NA.

  • arrow specification for arrow heads, as created by arrow(), defaults to NULL.

  • arrow.fill fill color to usse for the arrow head (if closed), defaults to 'NULL', meaning use 'colour' aesthetic.

Details

'geom_tiplab' not only supports using text or label geom to display tip labels, but also supports image geom to label tip with image files or phylopics.

For adding tip labels to a tree with circular layout, 'geom_tiplab' will automatically adjust the angle of the tip labels to the tree by internally calling 'geom_tiplab2'.

Value

tip label layer

Author(s)

Guangchuang Yu

References

For more detailed demonstration, please refer to chapter 4.3.3 of Data Integration, Manipulation and Visualization of Phylogenetic Trees http://yulab-smu.top/treedata-book/index.html by Guangchuang Yu.

Examples

require(ape)
tr <- rtree(10)
ggtree(tr) + geom_tiplab()

GuangchuangYu/ggtree documentation built on April 12, 2024, 5:20 a.m.