Rev 78954 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
% File src/library/grid/man/grid.record.Rd% Part of the R package, https://www.R-project.org% Copyright 2009-2020 R Core Team% Distributed under GPL 2 or later\name{grid.raster}\alias{grid.raster}\alias{rasterGrob}\title{Render a raster object}\description{Render a raster object (bitmap image) at the given location, size,and orientation.}\usage{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)}\arguments{\item{image}{Any R object that can be coerced to a raster object.}\item{x}{A numeric vector or unit object specifying x-location.}\item{y}{A numeric vector or unit object specifying y-location.}\item{width}{A numeric vector or unit object specifying width.}\item{height}{A numeric vector or unit object specifying height.}\item{just}{The justification of the rectanglerelative to its (x, y) location. If there are two values, the firstvalue specifies horizontal justification and the second value specifiesvertical justification. Possible string values are: \code{"left"},\code{"right"}, \code{"centre"}, \code{"center"}, \code{"bottom"},and \code{"top"}. For numeric values, 0 means left alignmentand 1 means right alignment.}\item{hjust}{A numeric vector specifying horizontal justification.If specified, overrides the \code{just} setting.}\item{vjust}{A numeric vector specifying vertical justification.If specified, overrides the \code{just} setting.}\item{default.units}{A string indicating the default units to useif \code{x}, \code{y}, \code{width}, or \code{height}are only given as numeric vectors.}\item{name}{ A character identifier. }\item{gp}{An object of class \code{"gpar"}, typically the outputfrom a call to the function \code{\link{gpar}}. This is basicallya list of graphical parameter settings.}\item{vp}{A Grid viewport object (or NULL).}\item{interpolate}{A logical value indicating whether to linearly interpolate theimage (the alternative is to use nearest-neighbour interpolation,which gives a more blocky result).}}\details{Neither \code{width} nor \code{height} needs to be specified,in which case, the aspect ratio of the image is preserved. Ifboth \code{width} and \code{height} are specified, it is likelythat the image will be distorted.Not all graphics devices are capable of rendering raster imagesand some may not be able to produce rotated images (i.e., ifa raster object is rendered within a rotated viewport). See also thecomments under \code{\link{rasterImage}}.All graphical parameter settings in \code{gp} will be ignored,including \code{alpha}.}\value{A rastergrob grob.}\author{Paul Murrell}\seealso{\code{\link{as.raster}}.\code{\link{dev.capabilities}} to see if it is supported.}\examples{redGradient <- matrix(hcl(0, 80, seq(50, 80, 10)),nrow=4, ncol=5)# interpolatedgrid.newpage()grid.raster(redGradient)# blockygrid.newpage()grid.raster(redGradient, interpolate=FALSE)# blocky and stretchedgrid.newpage()grid.raster(redGradient, interpolate=FALSE, height=unit(1, "npc"))# The same raster drawn several timesgrid.newpage()grid.raster(0, x=1:3/4, y=1:3/4, width=.1, interpolate=FALSE)}\keyword{ dplot }