annoTriangle: annoTriangle

View source: R/annoTriangle.R

annoTriangleR Documentation

annoTriangle

Description

This function is used to add triangle annotations in plot.

Usage

annoTriangle(
  object = NULL,
  relSideDist = 0.1,
  annoPos = "top",
  xPosition = NULL,
  yPosition = NULL,
  fillCol = NULL,
  nCol = 100,
  addTriangle = TRUE,
  triangleType = "RD",
  addBorder = FALSE,
  borderCol = "black",
  lty = NULL,
  lwd = NULL,
  myFacetGrou = NULL,
  aes_x = NULL,
  aes_y = NULL
)

Arguments

object

Your ggplot list. Default(NULL).

relSideDist

The relative distance ratio to the y axis range. Default(0.1).

annoPos

The position for the annotation to be added. Default("top").

xPosition

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

yPosition

The y axis coordinate for the triangle. Default(NULL).

fillCol

The triangle fill colors. Default(NULL).

nCol

The colors bins. Default(100).

addTriangle

Whether add triangle annotation. Default("TRUE").

triangleType

The triangle shape type, "RU"(right-up), "RD"(right-down), "LU"(left-up), "LD"(left-down). Default("RD").

addBorder

Whether add border to triangle or rect annotation. Default("FALSE").

borderCol

The border color. Default("black").

lty

The border lty. Default(NULL).

lwd

The border lwd. Default(NULL).

myFacetGrou

Your facet group name to be added with annotation when object is a faceted object. Default(NULL).

aes_x

= NULL You should supply the plot X mapping name when annotate a facetd plot. Default(NULL).

aes_y

= NULL You should supply the plot Y mapping name when annotate a facetd plot. Default(NULL).

Value

Return a ggplot object.

Author(s)

Junjun Lao

Examples

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

# load test data
data(p)

p1 <- p +
 ggplot2::theme(plot.margin = ggplot2::margin(t = 2,unit = 'cm'))

# default plot
annoTriangle(object = p1,
            annoPos = 'top',
            xPosition = c(0,10.5))

# ajust yposition
annoTriangle(object = p1,
            annoPos = 'top',
            xPosition = c(0.5,10.5),
            yPosition = c(10.8,11.5))

# add border
annoTriangle(object = p1,
            annoPos = 'top',
            xPosition = c(0.5,10.5),
            yPosition = c(10.8,11.5),
            addBorder = TRUE,
            lwd = 2.5)


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