1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/annotation-custom.R
\name{annotation_custom}
\alias{annotation_custom}
\title{Annotation: Custom grob}
\usage{
annotation_custom(grob, xmin = -Inf, xmax = Inf, ymin = -Inf, ymax = Inf)
}
\arguments{
\item{grob}{grob to display}
\item{xmin, xmax}{x location (in data coordinates) giving horizontal
location of raster}
\item{ymin, ymax}{y location (in data coordinates) giving vertical
location of raster}
}
\description{
This is a special geom intended for use as static annotations
that are the same in every panel. These annotations will not
affect scales (i.e. the x and y axes will not grow to cover the range
of the grob, and the grob will not be modified by any ggplot settings
or mappings).
}
\details{
Most useful for adding tables, inset plots, and other grid-based decorations.
}
\note{
\code{annotation_custom()} expects the grob to fill the entire viewport
defined by xmin, xmax, ymin, ymax. Grobs with a different (absolute) size
will be center-justified in that region.
Inf values can be used to fill the full plot panel (see examples).
}
\examples{
# Dummy plot
df <- data.frame(x = 1:10, y = 1:10)
base <- ggplot(df, aes(x, y)) +
geom_blank() +
theme_bw()
# Full panel annotation
base + annotation_custom(
grob = grid::roundrectGrob(),
xmin = -Inf, xmax = Inf, ymin = -Inf, ymax = Inf
)
# Inset plot
df2 <- data.frame(x = 1 , y = 1)
g <- ggplotGrob(ggplot(df2, aes(x, y)) +
geom_point() +
theme(plot.background = element_rect(colour = "black")))
base +
annotation_custom(grob = g, xmin = 1, xmax = 10, ymin = 8, ymax = 10)
}
|