addLegend: Adds a legend

View source: R/plotting.R

addLegendR Documentation

Adds a legend

Description

Adds a legend to a plot2D figure.

Usage

addLegend(
  object,
  fcol = "markers",
  where = c("bottomleft", "bottom", "bottomright", "left", "topleft", "top", "topright",
    "right", "center", "other"),
  col,
  bg,
  palette = "light",
  t = 0.3,
  pch,
  lwd,
  bty = "n",
  unknown = "unknown",
  ...
)

Arguments

object

An instance of class MSnSet

fcol

Feature meta-data label (fData column name) defining the groups to be differentiated using different colours. Default is markers.

where

One of "bottomleft" (default), "bottomright", "topleft", "topright" or "other" defining the location of the legend. "other" opens a new graphics device, while the other locations are passed to legend.

col

A character defining point colours.

bg

background (fill) color for the open plot symbols given by pch = 21:25.

palette

A character defining which palette colour theme to use, can either defined as "light" (default) or "dark".

t

A numeric between 0 and 1. Defining the degree of lightening of the colours in the palette. Default is 0.3.

pch

A character of appropriate length defining point character.

lwd

A numeric defining the line width for drawing symbols. Default is 1.5.

bty

Box type, as in legend. Default is set to "n".

unknown

A character (default is "unknown") defining how proteins of unknown/un-labelled localisation are labelled.

...

Additional parameters passed to legend.

Details

The function has been updated in version 1.3.6 to recycle the default colours when more organelle classes are provided. See plot2D for details.

Value

Invisibly returns NULL

Author(s)

Laurent Gatto, Lisa Breckels

Examples

## Load an example MSnSet
library("pRolocdata")
data(dunkley2006)

## Adding a legend inside a plot
plot2D(dunkley2006)
addLegend(dunkley2006,  where = "topleft")

## Adding a legend outside a plot
par(mfrow = c(1, 2))
plot2D(dunkley2006)
addLegend(dunkley2006, where = "other")

lgatto/pRoloc documentation built on June 14, 2025, 7:56 p.m.