grid.raster {grid} | R Documentation |
Render a raster object (bitmap image) at the given location, size, and orientation.
grid.raster(image, x = unit(0.5, "npc"), y = unit(0.5, "npc"), width = NULL, height = NULL, just = "centre", hjust = NULL, vjust = NULL, interpolate = TRUE, default.units = "npc", name = NULL, gp = gpar(), vp = NULL) rasterGrob(image, x = unit(0.5, "npc"), y = unit(0.5, "npc"), width = NULL, height = NULL, just = "centre", hjust = NULL, vjust = NULL, interpolate = TRUE, default.units = "npc", name = NULL, gp = gpar(), vp = NULL)
image |
Any R object that can be coerced to a raster object. |
x |
A numeric vector or unit object specifying x-location. |
y |
A numeric vector or unit object specifying y-location. |
width |
A numeric vector or unit object specifying width. |
height |
A numeric vector or unit object specifying height. |
just |
The justification of the rectangle
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 |
default.units |
A string indicating the default units to use
if |
name |
A character identifier. |
gp |
An object of class |
vp |
A Grid viewport object (or NULL). |
interpolate |
A logical value indicating whether to linearly interpolate the image (the alternative is to use nearest-neighbour interpolation, which gives a more blocky result). |
Neither width
nor height
needs to be specified,
in which case, the aspect ratio of the image is preserved. If
both width
and height
are specified, it is likely
that the image will be distorted.
Not all graphics devices are capable of rendering raster images
and some may not be able to produce rotated images (i.e., if
a raster object is rendered within a rotated viewport). See also the
comments under rasterImage
.
All graphical parameter settings in gp
will be ignored,
including alpha
.
A rastergrob grob.
Paul Murrell
dev.capabilities
to see if it is supported.
redGradient <- matrix(hcl(0, 80, seq(50, 80, 10)), nrow=4, ncol=5) # interpolated grid.newpage() grid.raster(redGradient) # blocky grid.newpage() grid.raster(redGradient, interpolate=FALSE) # blocky and stretched grid.newpage() grid.raster(redGradient, interpolate=FALSE, height=unit(1, "npc")) # The same raster drawn several times grid.newpage() grid.raster(0, x=1:3/4, y=1:3/4, w=.1, interp=FALSE)