Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

55 lines (51 sloc) 1.617 kb
\title{Annotation: Custom grob.}
annotation_custom(grob, xmin = -Inf, xmax = Inf,
ymin = -Inf, ymax = Inf)
\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}
This is a special geom intended for use as static
annnotations that are the same in every panel. These
anotations 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
Most useful for adding tables, inset plots, and other
grid-based decorations.
\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).
# Dummy plot
base <- qplot(1:10, 1:10, geom = "blank") + theme_bw()
# Adding a table
base + annotation_custom(grob = tableGrob(head(iris[ ,1:3])),
xmin = 3, xmax = 6, ymin = 2, ymax = 8)
# full panel
base + annotation_custom(grob = roundrectGrob(),
xmin = -Inf, xmax = Inf, ymin = -Inf, ymax = Inf)
# Inset plot
g <- ggplotGrob(qplot(1, 1) +
theme(plot.background = element_rect(colour = "black")))
base +
annotation_custom(grob = g, xmin = 1, xmax = 10, ymin = 8, ymax = 10)
Jump to Line
Something went wrong with that request. Please try again.