annoLegend: annoLegend

View source: R/annoLegend.R

annoLegendR Documentation

annoLegend

Description

This function is used to add legend annotations in plot.

Usage

annoLegend(
  object = NULL,
  relPos = c(0.9, 0.9),
  xPosition = NULL,
  yPosition = NULL,
  labels = NULL,
  vgap = 1,
  hgap = 1,
  cex = 1,
  pch = NULL,
  ncol = 1,
  col = NULL,
  fill = NULL,
  do.lines = FALSE,
  lines.first = FALSE,
  textSize = NULL,
  fontfamily = NULL,
  fontface = NULL
)

Arguments

object

This function is used to add segment annotations in plot.

relPos

The relative position of legend. Default(c(0.9,0.9)).

xPosition

The x axis coordinate for the legend. Default(NULL).

yPosition

The x axis coordinate for the legend. Default(NULL).

labels

The legend text labels. Default(NULL).

vgap

Vertical space between the legend entries. Default(1).

hgap

Horizontal space between the legend entries. Default(1).

cex

The legend key size. Default(1).

pch

Legend shape. Default(NULL).

ncol

Legend columns to show. Default(NULL).

col

Legend colors. Default(NULL).

fill

Legend fill colors. Default(NULL).

do.lines

Whether to show lines. Default(FALSE).

lines.first

Whether to show lines first. Default(FALSE).

textSize

Legend text size. Default(NULL).

fontfamily

Legend text fontfamily. Default(NULL).

fontface

Legend text fontface. Default(NULL).

Value

Return a ggplot object.

Author(s)

Junjun Lao

Examples

# ===============================
# test function

# load data
data(p)

# add legend
annoLegend(object = p,
           labels = paste('legend ',1:5),
           pch = 21,
           col = 'black',
           fill = useMyCol('paired',5),
           textSize = 15)

# change pos
annoLegend(object = p,
           relPos = c(0.2,0.9),
           labels = paste('legend ',1:5),
           pch = 21,
           col = 'black',
           fill = useMyCol('paired',5),
           textSize = 15)

jjAnno documentation built on Aug. 23, 2022, 9:06 a.m.