Last chance! 50% off unlimited learning
Sale ends in
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)
"left"
,
"right"
, "centre"
, "center"
, "bottom"
,
and "top"
. For numeric values, 0 means left alignment
and 1 means right alignment.
just
setting.just
setting.x
, y
, width
, or height
are only given as numeric vectors.gpar
, typically the output
from a call to the function gpar
. This is basically
a list of graphical parameter settings.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
.
as.raster
. 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)
Run the code above in your browser using DataLab