anno_plot: Annotations ggplot2 plot

View source: R/anno_plot.R

anno_plotR Documentation

Annotations ggplot2 plot

Description

Annotations ggplot2 plot

Usage

anno_plot(
  geom = "plot",
  x = NULL,
  y = NULL,
  xmin = NULL,
  xmax = NULL,
  ymin = NULL,
  ymax = NULL,
  xend = NULL,
  yend = NULL,
  na.rm = FALSE,
  label = NULL,
  ...
)

Arguments

geom

character Name of geom to use for annotation.

x, y, xmin, ymin, xmax, ymax, xend, yend,

numeric Positioning aesthetics - you must specify at least one of these.

na.rm

logical If FALSE, the default, missing values are removed with a warning. If TRUE, missing values are silently removed.

label

character, data.frame, ggplot or grob.

...

Other named arguments passed on to layer(). These are often aesthetics, used to set an aesthetic to a fixed value, like color = "red" or size = 3. They may also be parameters to the paired geom/stat.

Value

A plot layer instance.

Examples

p <- ggplot(mtcars, aes(x = wt, y = mpg)) + geom_point()
p + anno_plot("text", x = 5, y = 32, label = "Some text")
p + anno_plot("label", x = c(2, 5), y = c(15, 32), label = c("A", "B"))
p + anno_plot("plot", x = 5.5, y = 34, label = p + theme_bw(9), vp.width = 0.3, vp.height = 0.4)
p + anno_plot("rect", xmin = 3, xmax = 4.2, ymin = -Inf, ymax = Inf, alpha = .2, fill = "darkred")
p + anno_plot("segment", x = 2.5, xend = 4, y = 15, yend = 25, colour = "blue")
p + anno_plot("pointrange", x = 3.5, y = 20, ymin = 12, ymax = 28, colour = "red", size = 1.5)


ZhonghuiGai/gfun documentation built on Feb. 10, 2023, 6:10 p.m.