Description Usage Arguments Value Author(s) Examples
This is a modification to the R function image that adds a colorbar to the margin.
| 1 2 3 4 5 | 
| x, y | Locations of grid lines at which the values in  | 
| z | A matrix containing the values to be plotted ( | 
| xlim, ylim | Ranges for the plotted  | 
| zlim | The minimum and maximum  | 
| zlab | Label for the colorbar. | 
| zcex.axis | The magnification to be used for the z-axis annotation (colorbar scale). | 
| zcex.lab | The magnification to be used for the z-axis label ( | 
| zaxis.at | The points at which tick-marks are to be drawn for the colorbar. Points outside of the range of  | 
| zaxis.labels | This can either be a logical value specifying whether (numerical) annotations are to be made at the tickmarks, or a character or expression vector of labels to be placed at the tickpoints. | 
| col | Color scheme to use. Default is from  | 
| ncolor | The number of colors to use in the color scheme. | 
| drawbar | Logical indicating if the colorbar should be drawn. | 
| zline | Number of lines into the margin at which the axis line will be drawn (see  | 
| pltimage | A vector of the form c(x1, x2, y1, y2) giving the coordinates of the image region as fractions of the current figure region (see  | 
| pltbar | A vector of the form c(x1, x2, y1, y2) giving the coordinates of the colorbar region as fractions of the current figure region (see  | 
| ... | Additional arguments to be passed to  | 
Produces an image plot with a colorbar.
Nathaniel E. Helwig <helwig@umn.edu>
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | ##########   EXAMPLE 1   ##########
myfun <- function(x){
  2*sin(sqrt(x[,1]^2+x[,2]^2+.1))/sqrt(x[,1]^2+x[,2]^2+.1)
}
x <- expand.grid(seq(-8,8,l=100),seq(-8,8,l=100))
imagebar(seq(-8,8,l=100),seq(-8,8,l=100),matrix(myfun(x),100,100),
         xlab=expression(italic(x)[1]),ylab=expression(italic(x)[2]),
         zlab=expression(hat(italic(y))),zlim=c(-0.5,2),zaxis.at=seq(-0.5,2,by=0.5))
##########   EXAMPLE 2   ##########
myfun <- function(x1v,x2v){
  sin(2*pi*x1v) + 2*sin(sqrt(x2v^2+.1))/sqrt(x2v^2+.1)
}
x <- expand.grid(x1v=seq(0,1,l=100),x2v=seq(-8,8,l=100))
imagebar(seq(0,1,l=100),seq(-8,8,l=100),matrix(myfun(x$x1v,x$x2v),100,100),
         col=c("red","orange","yellow","white"),xlab="x1v",ylab="x2v",
         zlab=expression(hat(italic(y))),zlim=c(-1.5,3),zaxis.at=seq(-1.5,3,by=0.5))
##########   EXAMPLE 3   ##########
myfun <- function(x1v,x2v){
  sin(3*pi*x1v) + sin(2*pi*x2v) + 3*cos(pi*(x1v-x2v))
}
x <- expand.grid(x1v=seq(-1,1,l=100),x2v=seq(-1,1,l=100))
imagebar(seq(-1,1,l=100),seq(-1,1,l=100),matrix(myfun(x$x1v,x$x2v),100,100),
         col=c("blue","green","light green","yellow"),xlab="x1v",ylab="x2v",
         zlab=expression(hat(italic(y))),zlim=c(-5,5),zaxis.at=c(-5,0,5),
         zaxis.labels=c("low","med","high"))
 | 
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.