Description Usage Arguments See Also Examples
This function produces text as does grid.text
, but
also generates a background rectangle through
grid.rect
. Helpful for plotting e.g. overlaying
correlation statistics on a plot, where you'd like the
element to stand out a little more.
1 2 3 4 5 | grid.text2(label, x = unit(0.5, "npc"), y = unit(0.5, "npc"),
just = "centre", hjust = NULL, vjust = NULL, check.overlap = FALSE,
default.units = "npc", name = NULL, gp = gpar(col = "black", fill =
"grey92", lineend = "butt", linejoin = "round"), draw = TRUE, vp = NULL,
widthAdj = unit(0.05, "npc"), heightAdj = unit(0.05, "npc"))
|
label |
A character or |
x |
A numeric vector or unit object specifying x-values. |
y |
A numeric vector or unit object specifying y-values. |
just |
The justification of the text relative to its
(x, y) location. If there are two values, the first value
specifies horizontal justification and the second value
specifies vertical justification. Possible string values
are: |
hjust |
A numeric vector specifying horizontal
justification. If specified, overrides the |
vjust |
A numeric vector specifying vertical
justification. If specified, overrides the |
check.overlap |
A logical value to indicate whether to check for and omit overlapping text. |
default.units |
A string indicating the default
units to use if |
name |
A character identifier. |
gp |
An object of class |
draw |
A logical value indiciating whether graphics output should be produced. |
vp |
A Grid viewport object (or |
widthAdj |
A width adjustment parameter, to help control how much horizontal padding there should be between the text and the background rectangle. |
heightAdj |
A height adjustment parameter, to help control how much vertical padding there should be between the text and the background rectangle. |
1 2 3 4 5 6 7 8 9 10 11 | x <- rnorm(10)
y <- rnorm(10)
if (require(lattice)) xyplot( y ~ x,
panel = function(x, y, ...) {
panel.xyplot(x, y, ...)
grid.text2("some text\nwith a nice\nbackground")
grid.text2( expression( sum(x[i], i==1, n)^2 ), x=0.8, y=0.8 )
grid.text2( paste("sum of rnorm(10): ", sum(rnorm(10)) ), x=0.2, y=0.2, just="left" )
grid.text2( "horizontal justifications work too", x=0.95, y=0.35, just="right" )
})
## will work for multi-panel plots as well
|
Loading required package: lattice
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.