You are on page 1of 80

Package ‘plot3D’

February 20, 2015
Version 1.0-2
Title Plotting multi-dimensional data.
Author Karline Soetaert <karline.soetaert@nioz.nl>
Maintainer Karline Soetaert <karline.soetaert@nioz.nl>
Depends R (>= 2.15)
Imports misc3d
Description Functions for viewing 2-D and 3-D data, including perspective plots, slice plots, surface plots, scatter plots, ... Includes data sets from oceanography
License GPL (>= 3.0)
LazyData yes
Repository CRAN
Repository/R-Forge/Project plot3d
Repository/R-Forge/Revision 92
Repository/R-Forge/DateTimeStamp 2014-11-04 14:14:03
Date/Publication 2014-11-07 18:07:53
NeedsCompilation no

R topics documented:
plot3D-package . . . . . . . . . . . . . . . . . . .
2-D data set . . . . . . . . . . . . . . . . . . . . .
2D image and contour plots . . . . . . . . . . . . .
3-D arrows, segments, polygons, boxes, rectangles
3-D contours . . . . . . . . . . . . . . . . . . . .
3-D data set . . . . . . . . . . . . . . . . . . . . .
3-D perspectives . . . . . . . . . . . . . . . . . .
3-D surfaces . . . . . . . . . . . . . . . . . . . . .
3-D volume visualisation . . . . . . . . . . . . . .
Color key legend . . . . . . . . . . . . . . . . . .
Colors . . . . . . . . . . . . . . . . . . . . . . . .
Composite plots . . . . . . . . . . . . . . . . . . .
1

.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.

2
4
6
13
20
23
25
33
39
46
50
54

2

plot3D-package
images in 3D frame
Mesh generation . .
Perspective box . .
Scatter plots . . . .
trans3D . . . . . .

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

Index

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

59
62
63
66
76
78

plot3D-package

Plotting multi-dimensional data.

Description
Functions for visualising 2-D and 3-D data.
Many of the functions are extensions of R’s persp or image function.
Other packages that provide visualisation of 3-D data (and which might be better suited) are:
rgl, scatterplot3D, misc3D.
Note
This package is dedicated to Carlo
Note
Some of the functions based on persp will not work properly for all values of phi (which turns
the plots upside-down). This is because an assumption is made as to how the perspective plots are
viewed.
Author(s)
Karline Soetaert
References
http://www.rforscience.com/rpackages/visualisation/oceanview/
http://www.rforscience.com/rpackages/visualisation/plot3d/
See Also
Functions that are based on the persp function:
• persp3D: an extended version of persp.
• ribbon3D: a perspective plot as ribbons.
• hist3D: 3-D histograms.
• scatter3D, points3D, lines3D: colored points, lines, ... in 3-D.
• slice3D, slicecont3D: slices from a full 3-D data set.
• isosurf3D: isosurfaces from a full 3-D data set as triangles.

plot3D-package

3

• voxel3D: isosurfaces from a full 3-D data set as points.
• surf3D, spheresurf3D: 3-D shapes or surfaces.
• arrows3D: arrows in 3-D.
• segments3D: line segments in 3-D.
• polygon3D: 3-D polygons.
• box3D, border3D, rect3D: boxes and rectangles in 3-D.
• text3D: labels in 3-D.
Functions defined on the image function:
• image2D, for an image function to visualise 2-D or 3-D data.
• ImageOcean: an image of the ocean’s bathymetry.
Other plotting functions:
• contour2D, for a contour function to visualise 2-D data and that have a color key.
• scatter2D: colored points, lines, ... in 2-D.
• text2D, arrows2D, segments2D, rect2D, polygon2D for other 2D functions that have a color
key.
Colors and colorkey:
• colkey: adds a color legend.
• jet.col, ramp.col, gg.col, alpha.col: suitable colors, shade and lighting.
Utility functions:
• mesh: to generate rectangular (x, y) or (x, y, z) meshes.
Data sets:
• Oxsat: 3-D data set with the ocean’s oxygen saturation values.
• Hypsometry: 2-D data set with the worlds elevation and ocean’s bathymetry.
Examples
# run all examples
## Not run:
example(persp3D)
example(surf3D)
example(slice3D)
example(scatter3D)
example(segments3D)
example(image2D)
example(image3D)
example(contour3D)
example(colkey)
example(jet.col)
example(perspbox)
example(mesh)

4

2-D data set
example(trans3D)
example(plot.plist)
example(ImageOcean)
example(Oxsat)
## End(Not run)

2-D data set

The earths hypsometry (land elevation) and the ocean’s bathymetry

Description
Hypsometry is a relatively crude data set of the earths land elevation (positive) and ocean depth
(negative), at 1 dg intervals.
ImageOcean plots the ocean’s bathymetry.
Usage
ImageOcean (...)
Hypsometry
Arguments
...

arguments passed to function image2D.

Format
A list with the bathymetry (depth) and hypsometry (altitude) of the world. It contains:
x the latitude,
y the longitude,
z the height (m).
Details
Hypsometry is based on dataset Bathymetry from the R-package marelac.
Author(s)
Karline Soetaert <karline.soetaert@nioz.nl>
See Also
image2D, for the image function that visualises the bathymetry

ylab = expression(degree*N). contour = TRUE) ImageOcean(col = "white". z.perspbox(z = Hypsometry$z[ii. theta = 30. zlab = "depth". 0). colkey = list(side = 1)) # A function that makes a black panel with grey edge: panelfunc <. zlim[1])) 5 . jj]. xlab = "longitude". 2)) image2D(Hypsometry. pmat = pmat) polygon(XY$x. expand = 0. 2)) ii <.5.par("mar") ## ======================================================================= ## Images of the hypsometry ## ======================================================================= par(mfrow = c(2. d = 2. 1. border = "grey") } # left panel panelfunc(x = c(0. contour = TRUE) # remove ocean zz <. mar = c(2.c(-10000. 0) pmat <. 2. by = 2000))) ## ======================================================================= ## A complex image of part of the ocean ## ======================================================================= # elaborate version par(mfrow = c(1. z) { XY <. 0. y = c(0. contour = list(levels = seq(-6000.par("mfrow") mar <. xlab = expression(degree*E). col = "black". 2.which(Hypsometry$y > 10 & Hypsometry$y < 40) # Draw empty persp box zlim <.trans3D(x. 1). y. zlim = zlim. asp = TRUE. y. y = Hypsometry$y. z = c(zlim[1]. zlim[2].Hypsometry$z zz[zz < 0] <.function(x.2-D data set Examples # save plotting parameters pm <.which(Hypsometry$x > -50 & Hypsometry$x < -20) jj <. x = Hypsometry$x.NA image2D(zz. 0. phi = 20. NAcol = "black") ## ======================================================================= ## A short version for plotting the Ocean's bathymetry ## ======================================================================= ImageOcean(asp = TRUE. 1). XY$y. zlim[2]. 0. 0. ylab = "latitude".

xlab = "longitude".. colkey = NULL. y = seq(0. side = c("zmin". clab = NULL. 1. resfac = 4. 1. dist = -0.1)) ## End(Not run) # reset plotting parameters par(mfrow = pm) par(mar = mar) 2D image and contour plots Extended image and contour plots for 2-D (and 3-D) data. clab = "depth. phi = 20. z = c(zlim[1].6 2D image and contour plots # back panel panelfunc(x = c(0... side = c("zmin".. 0). colkey = list(side = 1. dist = -0. higher resolution ## Not run: persp3D(z = Hypsometry$z[ii. 0. theta = 30. m". "z")). zlim = zlim. zlab = "depth". zlim[1]. 2 times increased resolution. add = FALSE.jj]. 1).jj]. zlim[1])) # Actual bathymetry. Usage image2D (z.. NAcol = NULL. y = c(0. zlim = zlim. length.out = nrow(z)). 1. zlim[2]. d = 2.out = nrow(z)). . . 1. 1. colkey = list(side = 1. col = NULL. length = 0. zlim[1])) # bottom panel panelfunc(x = c(0.1)) # shorter alternative for same plot. length.5. clab = "depth. plot = TRUE) ## S3 method for class 'matrix' image2D(z.5. zlim[1].out = ncol(z)). . length. 1. contour2D extends R’s contour function. 1. ylab = "latitude". 0. "z")). y = c(1. contour = list(col = "grey". bty = "bl2". m". z = c(zlim[1]. Input can be a matrix (2-D) or an array (3-D) or a list. length = 0.) contour2D (z. x = seq(0. zlim[2]. Description image2D extends R’s image function. expand = 0. 1. resfac = 1. 1. contour = list(col = "grey". add = TRUE. resfac = 2. 1). x = seq(0. with contours persp3D(z = Hypsometry$z[ii. 1).5.

outer. border = NA. The label will be written at the same level as the main title. For instance. NAcol = "white". labels. List parameters should be one of side. lwd. lphi = 0. unless x. clab can be made a vector. lighting = FALSE.clab.ticks. To lower it.) ## S3 method for class 'list' image2D(z. for the x and y. colkey = NULL.values respectively.and y-values. plot = TRUE) ## S3 method for class 'array' image2D(z. add = FALSE. hence z also defines the variable used to color the image.e. plot.. NULL (default). with z-values. If resfac is one number then the resolution will be increased similarly in x and y-direction. clab = NULL. dist. width. ltheta = -135. NAcol Color to be used for NA values of z. See details. resfac = 1. Only when shade or lighting is toggled on does it make sense to use z different from colvar. x. plot = TRUE. See colkey.. length. the label to be written on top of the color key. theta = 0. colvar Only used when shade or lighting is toggled on. if colkey = FALSE.. shift. subset. If colkey = NULL then a color key will be added only if col is a vector.. width = 1. y are a matrix.2D image and contour plots 7 y = seq(0. contour = FALSE.out = ncol(z)). colkey A logical. in the right margin. If a matrix (only for image2D). for image2D. font. 1. Setting colkey = list(plot = FALSE) will create room for the color key without drawing it. pos. z will be interpolated to two intermediary points. margin = c(1. no color key legend will be added.. col. clab Only if colkey is not NULL or FALSE. shade = NA. ask = NULL. This uses simple linear interpolation. i. . colvar = z. with the first values empty strings. col Color palette to be used for the image function or for the contours. for contour2D. or a list with parameters for the color key (legend). then a contour plot will be added to the image plot. facets = TRUE. 2). dist = 0. If a vector x should be of length equal to nrow(z) and y should be of length equal to ncol(z). tick. .. lwd. one value or a vector of two numbers. . co The defaults for the parameters are side = 4.col(100). lty. . and the axis parameters at.. Also allowed is to pass a list with arguments for the contour function. The variable used to color the image. line. By default colvar is equal to z. length = 1. contour If TRUE. if resfac equals 3 then for each adjacent pair of x. y Vectors or matrix with x and y values. the default is to do nothing. length. the default is “white”.) Arguments z Matrix (2-D) or array (3-D) or a list with matrices or arrays. resfac Resolution factor. The default is to draw the color key on side = 4. A value > 1 will increase the resolution. rasterImage = FALSE. addlines. col = jet. they should have the same dimension as z.

the user is asked before each plot. If FALSE a new plot is started. Missing values are taken as FALSE. The default. . Will overrule shade not equal to NA. shade the degree of shading of the surface facets. polygon and contour. subset Either a logical expression indicating over which elements to loop. To switch on lighting. NA. ask A logical. theta The angle defining the azimuthal direction. ltheta. See persp. . 2). c(2. Implemented for consistency with the other functions based on persp. so it will appear smoother. a plot is created. Values of shade close to one yield shading similar to a point light source model and values close to zero produce no shading. This requires the x and y to be a vector with equally spaced elements. indicates to plot rows(x) and columns(y) and to loop over index 3. if TRUE. rasterImage linearly interpolates the image. or a vector or integers denoting the indices of the elements over which to loop. See examples in jet. then col denotes the color of the surface facets. then the surface facets are colored “white” and the border will be colored as specified by col. and 3. border The color of the lines drawn around the surface facets. the argument lighting should be either set to TRUE (using default settings) or it can be a list with specifications of one of the following: ambient.8 2D image and contour plots lighting If not FALSE the facets will be illuminated. rasterImage If TRUE. exponent.col. If NA then the facets will be transparent.. and colors may appear more bright. see par(ask) and dev.interactive. If TRUE. If TRUE (default). Values in the range 0. must be matched exactly.. rasterImage. For instance. add Logical. c(1. specular. See persp. facets If TRUE.5 to 0. additional arguments passed to the plotting methods image. lphi if finite values are specified for ltheta and lphi. Note that by default. alpha can be given a value inbetween 0 and 1 to make colors transparent. 1) will do the same but the image will be transposed. If FALSE. It is usually faster to draw with facets = FALSE. the surface is shaded as though it was being illuminated from the direction specified by azimuth ltheta and colatitude lphi. plot Logical. then the points will be added to the current plot. will disable the drawing of borders.75 provide an approximation to daylight illumination. The image function will loop over the index that is not in margin. margin should be a vector with two numbers inbetween 1. if NULL the user is only asked if more than one page of plots is necessary and the current graphics device is set interactive. diffuse. the function rasterImage will be used for plotting rather than image or polygon. The arguments after . otherwise (for 3D plots) the viewing transformation matrix is returned (as invisible). margin A vector giving the subscripts which the image function will be applied over. . sr and alpha. .

persp3D. while colvar will define the color.and y.values and x and y can be a matrix. Note The first argument.soetaert@nioz. z generally determines the color variable.par("mfrow") ## ======================================================================= ## Difference between x or y a vector/matrix and rasterImage ## ======================================================================= . either R-function image or rasterImage will be used.2D image and contour plots 9 Details image2D is an extension to the default image plot that has the possibility to add a color key and contourlines. plot. and no color key will be drawn. and to increase the resolution in order to make smoother images.and y.image from the fields package. another variable. colvar will only be used if shade or lighting are toggled on. colvar is also defined and set by default equal to z. both arguments zlim (as in image) and clim (as in the other plot3D functions) are accepted. Thus. This means that the x. the axis will not extend the x. one can safely add other plotting elements.or y.array and image2D. Value Returns nothing. See first example.col.nl> See Also jet. image and contour for the original R functions. it can deal with decreasing x. In this case. In contrast.values.list are versions that accept a 3 dimensional array respectively a list with z-matrices as their first argument to produce multiple plots. Upon returning from the image2D and contour2D functions. To set the ranges of the z-variable. when x and y are a matrix. both NA and NULL are allowed.axis will extend the x. if x and y are a vector.and y. scatter2D for other examples where image2D is used. the function uses R-function image. Examples # save plotting parameters pm <. For consistency with the other functions. For argument col of the image2D function. image2D. the figure coordinates are defined by the main figure (excluding the color key). It also uses a different color scheme. z will be used to define the shading (orientation of each facet). When x and y is a vector. In the latter case. Oxsat. in which case the color will be white. the image will be drawn as a set of polygons.values with half a grid cell. Author(s) Karline Soetaert <karline. ImageOcean.

col = jet.1:3 z <. main = "volcano".ncol(volcano) image2D(volcano. x = 1:nr. lighting = TRUE. x = matrix(nrow = 3.col(12). x. x. contour = TRUE. by = 10)) abline(h = seq(10. 40. border = "black") image2D(z. levels dashed col = "black". 30. m") image2D(volcano. y. lwd = 2) # imposed levels contour2D(z = V.150 # default.2.5. no color key contour2D(z = V. colkey = FALSE.volcano . y = 1:nc. ncol = 3. light. lwd = 2. 80. x = 1:nr. y = 1:nc. add = TRUE) . by = 20)) # negative levels contour2D(z = V. shade = 0. 2)) x <. lwd = 2. 2)) V <.y <.matrix (nrow = 3. = seq(0. 40. x = 1:nr. main = "volcano". lwd = 3. lwd = 2. x = 1:nr. 60. pch = 3. 2)) nr <. lwd = 2. levels contour2D(z = V.nrow(volcano) nc <. lphi = 0. m") abline(v = seq(10. clab = "height. border = "black") image2D(z. theta = 45) ## ======================================================================= ## shading. y. = seq(-40. ncol = 3. adding contours. m") ## ======================================================================= ## Contour plots ## ======================================================================= par(mfrow = c(2. points and lines ## ======================================================================= par(mfrow = c(2. y = 1:nc. levels = seq(-40. by = 20). cex = 5. shade = 0. data = x). main = "volcano". y. col = "white") image2D(z = volcano. by = 20)) col = "black". border = "black". border = "black") image2D(z. lty = 2. rasterImage = TRUE. data = 1:9) image2D(z. x. clab = "height. main = "volcano") image2D(volcano. col = "lightblue". y = 1:nc. by = 10)) points(50. clab = "height. -20.10 2D image and contour plots par(mfrow = c(2. y.

increase resolution z <."%")) # images at first 9 depths . nlevels = 20. main = "surface oxygen saturation data 2005". y = Oxsat$lat. mfrow = c(3. Oxsat$lat > . contour = TRUE. x = Oxsat$lon. clab = c("".1]. y = Oxsat$depth. 1)) image2D(z = Oxsat$val[. colorkey contour2D(z = V.Oxsat$val[. " m"). x = Oxsat$lon. zlim = list(c(80. "log(m)"). resfac = 3.5 & Oxsat$lat < 5]) ## ======================================================================= ## Image of a list of matrices ## ======================================================================= listvolcano <. margin = c(1.4. 0)) # show position of transects image2D(z = Oxsat$val[ . lwd = 2. NAcol = "black". 3). y = Oxsat$lat.depth section . 1]. m". y = 1:nc. 2). NAcol = "black") abline(h = Oxsat$lat[Oxsat$lat > . drawlabels = FALSE. input is an array ## ======================================================================= par(mfrow = c(1. main = paste("depth ". 11 . .5 & Oxsat$lat < 5. ylim = c(5000. imposed number of levels. NAcol = "black". Oxsat$val/100 * 360) image2D(z = listoxygen. y = Oxsat$lat."". 5.5))) ## ======================================================================= ## Image of a list of arrays ## ======================================================================= ## Not run: # crude conversion from oxsat to oxygen listoxygen <. . zlim = c(0. colkey = list(at = seq(-40. ylab = "latitude". subset = 1:9. x = Oxsat$lon. logvolcano = log(volcano)) image2D(listvolcano.2D image and contour plots # no labels. NAcol = "black". 3)) # images at latitude .use subset to select them image2D(z = Oxsat$val. by = 20))) ## ======================================================================= ## A large data set. margin = c(1. xlab = "longitude". "log(volcano)"). x = Oxsat$lon. x = 1:nr. 115). 200). 40. Oxsat$depth[1:9].list(volcano = volcano. ] image2D(z = z. c(4. clab = list("height. main = c("volcano".list(Oxsat$val.

zlim = c(1. panel. "m")) # logarithmic z-axis image2D(volcano. NAcol = "black". y = volcy.matrix(ncol = 87.110 VOLC [VOLC <= 0] <. nrow = 61. ncol = 61.out = 61)) volcy <. Oxsat$depth. main = "log='z'") # Including NAs VOLC <. NAcol = "black". 100).volcx + matrix(nrow = 87. length. log = "z". nrow = 61. ncol = 61. 'y' and 'z' are matrices ## ======================================================================= par(mfrow = c(2. mtext = paste("depth ". y = volcy) # use of panel function image2D(volcano.. main = c("Oxygen saturation ". data = 1:87) volcx <.12 2D image and contour plots x = Oxsat$lon. 1)) # tilted x. data = seq(0.NA image2D(VOLC.matrix(nrow = 87. "m"). " m") ) ## End(Not run) ## ======================================================================= ## 'x'. margin = c(1.volcano . length. NAcol = "black". clab = c("height". x = volcx. log = "z". data = seq(0. 2). 2)) # normal volcano image2D(volcano.first = substitute(box(col = "lightgrey"..out = 87))) image2D(volcano. 25. 15. x = volcx. y = Oxsat$lat. byrow = TRUE. data = 1:61) volcy <. clab = c("height". main = "including NAs and rescaled") # both image2D(VOLC. main = "NAs and log = 'z'") ## ======================================================================= ## Image with contour specification (alpha sets the transparency) ## ======================================================================= . byrow = TRUE. lwd = 30))) ## ======================================================================= ## Image with NAs and logs ## ======================================================================= par(mfrow = c(2.and y-coordinates of 'volcano' volcx <. " Oxygen concentration").t(volcy + matrix(ncol = 87.

panel. shade = 0. alpha = 0. segments2D. .first = NULL. Usage arrows3D (x0. y0.. NAcol = "white". boxes.5)) # same: ## Not run: image2D(z = volcano. phi = 40. Description Functions arrows3D and segments3D draw arrows and line segments between pairs of points. rect2D and polygon2D are included for their side effect of having a color key. . rectangles 13 par(mfrow = c(1.8. theta = 40.5. labcex = 0.. clim = NULL. phi = 40. alpha = 0. x1 = x0. polygons. polygons. z1 = z0. clim = NULL. lines. add = TRUE) ## End(Not run) # reset plotting parameters par(mfrow = pm) 3-D arrows. bty = "b".. rasterImage = TRUE. clab = NULL. lwd = 3. polygon3D draws polygons.first = NULL. segments.. shade = 0. y0. y1 = y0. type = "triangle".. y0. boxes. plot = TRUE) segments3D (x0. colvar = NULL. NAcol = "white". bty = "b". colkey = NULL. colkey = NULL. 1)) image2D(volcano. panel. . Functions box3D and border3D draw boxes between pairs of points. NAcol = "white". points. rectangles and boxes in a 3D perspective plot or in 2D. z0.. y1. clab = NULL. z1. contour = list(col = "white". theta = 40. z0.8. labcex = 0. theta = 40. x1.. col = "white". rectangles Plots arrows. x1 = x0. z1 = z0. border = NA. segments. rect3D draws rectangles. facets = TRUE.3-D arrows. y1 = y0. col = NULL. polygons. plot = TRUE) box3D (x0.. col = NULL. lwd = 3. col = NULL. add = FALSE. add = FALSE. phi = 40. segments. panel.2.first = NULL.. colvar = NULL. z0. rasterImage = TRUE) contour2D(z = volcano. . colkey = NULL. The 2D functions arrows2D.2. colvar = NULL.

facets colkey = NULL. plot = TRUE) segments2D (x0. bty = "b". ..first = NULL. clim = NULL. add = FALSE. TRUE) rect2D (x0. y0. col = NULL. clab = NULL. colvar = NULL. colvar = NULL.. plot = = NULL. x1 = NULL. z0 coordinates of points from which to draw. "white". colvar = NULL. plot = y1 = y0. panel. x1. z1. . .. y0. NAcol = "white". panel. NAcol = "white".. border = NA. col = NULL. add = FALSE. clab = NULL. clab = NULL. colvar col = NULL. clab = NULL. colkey = NULL.. colvar = NULL. col = NULL. border = NA.. clim = NULL. phi = 40.. = NULL. clab = NULL. type = "triangle".. NAcol = border = NA. clim = NULL. plot = TRUE) rect3D (x0. panel. col = NULL. facets = TRUE.14 3-D arrows. plot = TRUE) border3D(x0. NAcol = "white". clab = NULL. . z0. rectangles clim = NULL. y1 = y0. NAcol = "white".. boxes. . clab = NULL. x1 = x0. y1. TRUE) Arguments x0.. bty = "b". y0. colkey = NULL. col = NULL. clim add = FALSE. y0.. NAcol = colkey = NULL. theta = 40. col = NULL. add = FALSE. y1 = NULL. colkey = NULL. y.. clim add = FALSE. plot = TRUE) arrows2D (x0. bty = "b".first = NULL. phi = 40... NAcol = "white". . colvar = NULL. add = FALSE... y1 = y0. theta = 40. bty = "b". plot = TRUE) polygon2D (x. add = FALSE. = TRUE. x1 = x0.. y0. z0. facets = TRUE. y. colvar = NULL. z1 = NULL. theta = 40. segments. . clim = NULL. plot = TRUE) polygon3D (x. z. clab = NULL. "white". phi = 40. colkey = NULL. y0.. add = FALSE. . clim = NULL.first = NULL.. = NULL. colkey = NULL. polygons. x1 = x0...

length = 1. Colors to be used for colvar values that are NA. or a list with parameters for the color key (legend). it should be defined as function(pmat). Only if colkey is not NULL or FALSE. For rect3D exactly one must be NULL. y1. length. then col denotes the color of the surface facets. plot. in the right margin. See colkey.first clab clim bty type 15 coordinates of points to which to draw. dist = 0. one of "simple" (which uses R-function arrows). The polygon will be closed by joining the last point to the first point. NA. If col is NULL and colvar is not specified. If TRUE. it should be a vector of dimension equal to the coordinates or to the number of polygons.ticks. To lower it. If FALSE. Only effective if the persp argument (box) equals TRUE (this is the default). clab can be made a vector. plot = TRUE. at least one must be supplied. Color palette to be used for coloring the arrows or segments as specified by the colvar variable. NULL (default).g. The default. A function to be evaluated after the plot axes are set up but before any plotting takes place. It need not be present. List parameters should be one of side. The function should have as argument the transformation matrix. These NA values break the polygon into several complete polygons. the range of the color variable. for drawing background grids or scatterplot smooths. Only if colvar is specified. co The defaults for the parameters are side = 4. no color key legend will be added. This can be useful e. lty. y. lwd. or FALSE will toggle off coloration according to colvar.e. The type of the perspective box. then a red-yellow-blue colorscheme (jet. shift. polygons. rectangles x1.col) will be used.g. Values of NULL. boxes. lwd. the label to be written on top of the color key. NA. "curved" or "triangle" and "cone". The coordinates can contain missing values (NA). phi col NAcol colkey border facets panel. theta gives the azimuthal direction and phi the colatitude. pos. i. then col will be "black". and the axis parameters at. tick. z colvar theta. If NA then the facets will be transparent. line. The default is to draw the color key on side = 4. A logical. col. The type of the arrow head. then the surface facets are colored “white” and the border (if NA) will be colored as specified by col. e. The label will be written at the same level as the main title. The latter two are the same in plot3D (but differ in package plot3Drgl). coordinates of the vertices of the polygon. segments. The variable used for coloring. if colkey = FALSE. width = 1. See persp. The color of the lines drawn around the surface facets. but if specified. with the first values empty strings. Setting colkey = list(plot = FALSE) will create room for the color key without drawing it. See perspbox. Values of colvar that extend the range will be put to NA. width. dist. the angles defining the viewing direction. For arrows3D and segments3D. font. addlines. See example of persp3D and last example of voxel3D. It is usually faster to draw with facets = FALSE. If colkey = NULL then a color key will be added only if col is a vector. z1 x. used for the color key. outer. will disable the drawing of borders. .clab. the default draws only the back panels. labels. If col is NULL and colvar is specified.3-D arrows.

z0. clab = "z-value".panel. "green") arrows3D(x0. To select objects only within the axis limits. including those that fall out of these ranges. yy. colvar = z0. segments. All objects will be plotted.yy <. See Also arrows for the 2-D arrows function on which arrows3D is based. .. will be added to the current plot. ylab. See trans3D.panel. . alpha can be given a value inbetween 0 and 1 to make colors transparent.x0 + 0. col.par("mfrow") ## ======================================================================== ## arrows. 0.M$z x1 <. col = Col.seq(-0..mesh(xx. col. then the arrows. . y. If FALSE a new plot is started.M$y. x1 = x1.grid. rectangles add Logical. .seq(-0. and z values xx <. code. xlab. the following arrows arguments can be specified: length. lwd = 2. sub. use plotdev. otherwise the viewing transformation matrix is returned (as invisible).8.8. a plot is created.grid can also be given a value.2) zz <. The arguments xlim. zlim only affect the axes for 3D plots. boxes. ylim. The arguments after . In addition. For all the functions. shade and lighting arguments will have no effect. ylim.1. zlab. The following persp arguments can be specified: xlim. segments for the 2-D arrows function on which segments3D is based. lwd.8. length = 0. d = 2. . Examples # save plotting parameters pm <. must be matched exactly. y0 <.8.1 Col <.axis. y0. For polygon3D.. If TRUE (default). z0 <. points. 0. angle.16 3-D arrows. by = 0.. by = 0. polygons. Value Returns the viewing transformation matrix. segments. the following polygon arguments can be specified: border. lwd can be specified. For arrows3D.8) M <. If TRUE.c("red". lwd. zz) x0 <.M$x. box ## ======================================================================== # Create a grid of x. plot Logical. additional arguments passed to the plotting methods. the perspbox arguments col. "blue". segments. zlim. arguments lty. main.

col = Col) # use segments to add section x0 <. border = "black". add = TRUE. rectangles xlim = c(-0. 0.. x1 = 0. y0 = seq(-0. 0. phi = 20.1).1). y0. lty = 2.8. by = -0.c(-0. 0. -0. by = 0.1. y1. -0.8).col to set the transparency of a vector of colors 17 . ylim = c(-0.1). 0.1).col(8). -0.1. by = 0. polygons. y0.1. alpha = 0.) segments3D(x0.3-D arrows.1).8. y1 = seq(0. col = gg. y0 = seq(-0.8.8. add = TRUE.8. alpha = 0. -0. z0 = -0. -0. x1 = seq(0. 0.8. z1 = seq(0. 0. colvar = z0.8.1.8. x1 = seq(0. -0. by = -0. pch = ".1). add = TRUE.8. by = -0.8. col = "black".8.col(1. y1 = seq(0. segments. z1 = z0. z1 = 0. main = "arrows3D.8.8.1). main = "border3D") box3D(x0 = -0. col = gg.8.8. by = 0.1.1). lwd = 3) ## ======================================================================== ## boxes. segments3D.8. lwd = 2. by = 0. 0. 0.8) x1 <. z1 = seq(0.8). by = -0..1.1).c( 0.8.8. cubes ## ======================================================================== # borders are boxes without facets border3D(x0 = seq(-0. 0. by = 0. x1. points3D.1). -0. -0.8).1. col = rainbow(n = 8.8.1.8. 0. 0.8.8) z0 <. 0.1. y0 = -0.8. boxes. 0. 0.8) y1 <.8.".c(0. lwd = c(1.8.1. -0. -0.1.8. border = "black". 0. cex = 3. lwd = 2. 0. by = 0. -0.c(-0. border3D") # add starting point of arrows points3D(x0. 0. 0. by = -0. z0. phi = 20) # here the perspective does not always work # use alpha.8.8.8.8.8. main = "box3D") box3D(x0 = seq(-0.8. 0. z0 = seq(-0.1).c(-0.1).8. 0. colkey = FALSE.8.8. 4).1). col = "orange". z0 = seq(-0.8. lwd = 2) # add a box border3D(-0.8. -0.8) y0 <.8.1. y1 = 0. z0. -0.. 0.8. by = -0.

theta = 30.outer(x.8. X1. "orange"). y1 = runif(3). type = "curved". ylim = c(0. FUN = function (x. by = -0. bty = "g". lwd = 2. col = gg. x1 = 1. length = 30) z <.y <. col = "red") segments3D(X0. 1). z0 = 0. 10.8.y) y) Z0 <. col = "green") .8. Z1.Z0 + 10 arrows3D(X0. polygons. Y0. with colored facet rect3D(x0 = 0.outer(x. add = TRUE. -0. ylab = "Y". shade = 0. by = -0. z0 = runif(3). len = 6) X0 <. 0. add = TRUE.y) x^2 + y^2) X1 <. phi = 20. segments. col = "lightblue". z0 = seq(-0. col = c("red". y. by = 0. phi = 20) # add rect at constant z. add = TRUE) ## ======================================================================== ## arrows added to a persp plot ## ======================================================================== x <.18 3-D arrows. length(X0)). bty = "g". by = 0. alpha = 0. z1 = runif(3). x1 = 1. boxes. lwd = 2. y. rectangles box3D(x0 = runif(3). xlab = "X".X0 + 1 Y1 <. Y1. border = "black". x1 = seq(0. z1 = 5.75. border = "red". FUN = function(x.8. y. X0.y <. lwd = 2.y) x) Y0 <. -0.1). y.1. y. FUN = function (x. z. Z0.1. y0 = 0.1. y0 = runif(3).Y0 + 1 Z1 <. border = "black". rep(0. y1 = seq(0. main = "rect3D") # constant y and with transparent facets rect3D(x0 = 0. facets = NA.seq(-10. 10. z0 = 0.1.outer(x. -0. x1 = runif(3).1. zlab = "x^2+y^2" ) # Points where to put the arrows x <. FUN = function (x. phi = 30. Y0.seq(-10.col(8).5.1). y0 = seq(-0.1). border = "red". ltheta = 120. "lightblue". lwd = 2. ticktype = "detailed". y0 = 0. 0.1).y) x^2 + y^2) persp3D(x. Y0.outer(x.8.1). by = 0. lwd = 2) ## ======================================================================== ## rectangles ## ======================================================================== # at constant 'z' rect3D(x0 = seq(-0. y1 = 1. Z0.

polygons. colvar = 1:10. 36.runif(10) y <. separated by NAs x <. main = "arrows2D.3-D arrows.NA # transparent colors (alpha) polygon3D(x. separated by NAs x <. y0 = runif(10). lwd = 2.runif(10) y <. x1 = runif(10). lwd = 3.runif(59) 19 . x1 = runif(10).runif(39) ii <.runif(10) z <.z[ii] <. rectangles ## ======================================================================== ## polygon3D ## ======================================================================== x <. code = 3. y) # same as polygon # several polygons. col = gg. y1 = runif(10).runif(59) y <. z) # several polygons.runif(39) z <.y[ii] <.runif(39) y <. segments. border = "black". add = TRUE. segments2D") segments2D(x0 = runif(10). y1 = runif(10). y0 = runif(10).col(length(ii) + 1. main = "rect2D") ## ======================================================================== ## polygon2D ## ======================================================================== x <. y1 = runif(10).seq(4. by = 4) x[ii] <. alpha = 0.4. main = "polygon3D") ## ======================================================================== ## 2D examples. colvar = 1:10. colvar = 1:10.runif(10) polygon2D(x. colkey = FALSE) # transparency rect2D(x0 = runif(10). y. y0 = runif(10). z.8). x1 = runif(10). with color key ## ======================================================================== arrows2D(x0 = runif(10). y.runif(10) polygon3D(x. alpha = 0. lwd = 2. boxes.

the first vector should be of length equal to nrow(colvar) and the second should be of length equal to ncol(colvar).. col Color palette to be used for the colvar variable. or one value containing the values where the image is to be plotted. length.NA # transparent colors (alpha) polygon2D(x. If col is NULL and colvar is specified. pos. colvar = 1:(length(ii) + 1). tick. lwd. bty = "b". . dist = 0. shift. colkey = NULL. theta = 40. to the (x-z) plane (y one number) or to the (z-y) plane (z one number). This gives good results only if border is given a color. main = "polygon2D") # restore plotting parameters par(mfrow = pm) 3-D contours Contours in 3-D plots. labels. clim = NULL. . Usage contour3D (x = NULL. If two are vectors. colvar = NULL. parallel to the (y-z) plane (x one number). At least one of them should be one number. length = 1. by = 5) x[ii] <. addbox = TRUE.first = NULL.20 3-D contours ii <. z = NULL. 55. as this will determine where the image is plotted.seq(5. outer. dDepth = 1e-1. colkey A logical. col = NULL. Description contour3D adds a contour in a 3-D plot. phi = 40. dist. NA. then a red-yellow-blue colorscheme (jet. or a list with parameters for the color key (legend).ticks. vector. or when shade is >0 (see persp). y. or FALSE will toggle off coloration according to colvar. add = FALSE. Values of colvar equal to NULL. z Matrix (2-D). plot.col().y[ii] <.col) will be used. y = NULL.2. clab = NULL. co The defaults for the parameters are side = 4. List parameters should be one of side. plot = TRUE. line. NULL (default). width. y. colvar The variable used for coloring. lty. and the axis parameters at.. then col will be "black". border = "black". lwd. See colkey.. panel. lwd = 3. plot = TRUE) Arguments x. addlines. If col is NULL and colvar is not specified. alpha = 0.clab. col = gg. font. width = 1. col.

shade and lighting arguments will have no effect.first A function to be evaluated after the plot axes are set up but before any plotting takes place. main.3-D contours 21 The default is to draw the color key on side = 4. ylab. zlab.panel. dDepth When a contour is added on an image. zlim. if colkey = FALSE. xlab. The arguments xlim. ylim.g. zlim only affect the axes. the image polygons may hide some contour segments. must be matched exactly. Values of colvar that extend the range will be put to NA. col. ylim. e. the label to be written on top of the color key. See trans3D. the perspbox arguments col.panel. clab Only if colkey = TRUE. The label will be written at the same level as the main title. lwd can also be specified. lwd. a plot is created. The arguments after . otherwise the viewing transformation matrix is returned (as invisible). If TRUE (default). . . phi The angles defining the viewing direction. see persp.grid can also be given a value. lwd. The function should have as argument the transformation matrix. i. used for the color key. theta.. Setting colkey = list(plot = FALSE) will create room for the color key without drawing it. no color key legend will be added. The following persp arguments can be specified: xlim. To select objects only within the axis limits. theta gives the azimuthal direction and phi the colatitude. If colkey = NULL then a color key will be added only if col is a vector. then the contours will be added to the current plot. the default only drawing background panels. See perspbox. use plotdev. sub. in the right margin. panel. addbox If TRUE will draw a box around the plot. If FALSE a new plot is started. alpha can be given a value inbetween 0 and 1 to make colors transparent. col.e. . Too large values of dDepth may create visible artifacts. bty The type of the box. plot Logical.. . to make them appear in front of the polygons. clim Only if colvar is specified. The arguments lty. to lower it. Only effective if the persp argument (box) equals TRUE (this is the default).axis. the range of the color variable. See example of persp3D and last example of voxel3D. additional arguments passed to the plotting methods. Value Returns the viewing transformation matrix.grid. In addition. To avoid that. clab can be made a vector. add Logical. All objects will be plotted. If TRUE. including those that fall out of these ranges. it should be defined as function(pmat). with the first values empty strings. the viewing depth of the segments can be artificially decreased with the factor dDepth times the persp argument expand (usually = 1). This can be useful for drawing background grids or scatterplot smooths.

1.soetaert@nioz. col = "white". zlim = c(90. lwd = 2. "m")) contour3D(z = volcano.1:nrow(volcano) c <. colvar = volcano. y = c. colvar = volcano. "m")) contour3D(x = 100. "m"). col = "black") # default persp3D(z = volcano. clab = c("height". colvar = volcano. shade = 0. colvar = volcano. length. plot = FALSE) contour3D(z = volcano. clab = c("height". lwd = 2. col = "grey". nlevels = 20. col = "white". colkey = list(at = seq(90. shade = 0. clab = c("height". "m"). add = TRUE. plot = FALSE) contour3D(z = volcano.par("mfrow") ## ======================================================================= ## Contours ## ======================================================================= par (mfrow = c(2. 300). add = TRUE. Examples # save plotting parameters pm <. y = r. colvar = volcano. plot = FALSE. 150). lwd = 2. lwd = 2. "m")) ## ======================================================================= ## Composite images and contours in 3D ## ======================================================================= persp3D(z = volcano. colkey = FALSE) contour3D(y = volcano. nlevels = 5) ## ======================================================================= ## the viewing depth of contours (dDepth) ## ======================================================================= # too low persp3D(z = volcano. colvar = volcano.1:ncol(volcano) contour3D(x = r. lwd = 2. d = 2.1.nl> See Also contour for R’s 2-D contour function. dDepth = 0.out = 5))) contour3D(z = 300. 2)) r <. z = c.22 3-D contours Author(s) Karline Soetaert <karline. clab = c("height". add = TRUE. 190. nlevels = 20. zlim = c(0. col = "white".1. colvar = volcano. clab = c("height". z = 100. plot = FALSE) . shade = 0. nlevels = 10.

lwd = 1. the long name of the variable. lwd = 2. 180). col = "black") # too high persp3D(z = volcano.1. The values are gridded in 2dg * 2dg longitude . and converted to half the resolution for latitude and longitude.5.e. dDepth = 0.latitude sets. colvar = volcano. plot = FALSE) contour3D(z = volcano. and there are 33 depth intervals. the saturation value (%). the longitude (dg E). lat. 90 values. Description Percentage Oxygen Saturation from the NODC World Ocean Atlas 2005 (WOA05).1. depth). add = TRUE. Usage data(Oxsat) Format list with • lon. the water depth (m). (lon.nl> . 360) was changed to (-180. • units. the units of measurement.3-D data set 23 contour3D(z = volcano. val is an array of dimension (180. dDepth = 0. • depth. shade = 0. the original data from (0. at 2 dg resolution. at 2 dg resolution. Details The “objectively analyzed climatology” has been used to extract these data. 33). i. add = TRUE. 90. col = "white". Author(s) Karline Soetaert <karline. The original data were averaged over the 4 seasons. 33 values. col = "black") # reset plotting parameters par(mfrow = pm) 3-D data set Yearly averaged oxygen saturation from the NODC World Ocean Atlas 2005. The longitude was converted to the European view. • lat.soetaert@nioz. • name. the latitude (dg N). 180 values. colvar = volcano. • val.

.nodc.gov ftp://ftp. margin = c(2. 0). y = Oxsat$lat. z = -Oxsat$depth.which (Oxsat$lat > 0 & Oxsat$lat < 90) xs <. ys = ys.gov/pub/data.Oxsat$lon[ii[length(ii)]] # E boundary ys <. y = Oxsat$depth. December 2006 See Also image2D for plotting. y = Oxsat$lat[jj].nodc. x = Oxsat$lon[ii].24 3-D data set References http://www. CSIRO netCDF version of the NODC World Ocean Atlas 2005. 1)) ii <. 3).]. 1]. ylim = c(5500. Examples # save plotting parameters pm <. main = "surface oxygen saturation (%) for 2005") ## ======================================================================== ## plot a selection of latitude-depth profiles. . ylab = "depth. 1)) image2D(z = Oxsat$val[ . zs = 0. xs = xs. zlim = c(0. NAcol = "black".nodc/woa/WOA05nc/seasonal/ Originally made available by CSIRO: Mark A.Oxsat$lon image2D (z = Oxsat$val.noaa. x = Oxsat$lat.par("mfrow") ## ======================================================================== ## plot all surface data ## ======================================================================== par(mfrow = c(1.Oxsat$lat[jj[1]] # S boundary slice3D(colvar = Oxsat$val[ii. Collier and Paul J. x = Oxsat$lon.jj. xlab = "latitude".which (Oxsat$lon > -90 & Oxsat$lon < 90) jj <. Durack. m") ImageOcean() abline ( v = lon[lon > 18 & lon < 23]) ## ======================================================================== ## plot with slices ## ======================================================================== par(mfrow = c(1. 110). subset = (lon > 18 & lon < 23). input is an array ## ======================================================================== lon <. 2005. NAcol = "black". CSIRO Marine and Atmospheric Research Paper 015.noaa.

4. colvar = z. inttype = 1. plot = TRUE) hist3D (x = seq(0. along = "x". clab = NULL. xlab = "longitude". col = NULL. contour = FALSE. theta = 40. theta = 40. theta = 40. col = NULL.out = nrow(z)). clim = NULL. colvar = z. lighting = FALSE. clim = NULL. 1.. shade = NA. panel. plot = TRUE) .. panel. add = FALSE. image = FALSE. colkey = NULL. 1. colkey = NULL.. bty = "b".out = ncol(z)). border = NA.out = nrow(z)). clim = NULL.out = ncol(z)). 1. facets = TRUE. bty = "b". Usage persp3D (x = seq(0. image = FALSE. . phi = 40. space = 0. y = seq(0. phi = 50. bty = "b". contour = FALSE.3-D perspectives 25 theta = 35. panel. clab = "%".out = nrow(z)).first = NULL. ltheta = -135. curtain = FALSE. col = NULL. facets = TRUE. colkey = list(length = 0. . NAcol = "white". lighting = FALSE. lphi = 0.5). colkey = NULL. NAcol = "white". clab = NULL. contour = FALSE. z... phi = 40. space = 0. main = "Oxygen saturation". add = FALSE. z.. y = seq(0. 1. length.. add = FALSE. length. facets = TRUE. ylab = "latitude". length. y = seq(0. resfac = 1. 1. Description persp3D extends R’s persp function. z.5. NAcol = "white". lphi = 0. ticktype = "detailed". length... clab = NULL. plot = TRUE) ribbon3D (x = seq(0.first = NULL. ltheta = -135. hist3D generates 3-D histograms. border = NA.first = NULL. length. phi = 40. resfac = 1. length. border = NA. curtain = FALSE. shade = NA. 3-D ribbons and 3-D histograms. 1. image = FALSE.out = ncol(z)). . lphi = 0. zlab = "depth") # restore plotting parameters par(mfrow = pm) 3-D perspectives Perspective plots. ltheta = -135. lighting = FALSE. shade = NA. ribbon3D is similar to persp3D but has ribbon-like colored surfaces. colvar = z. expand = 0.

length.26 3-D perspectives Arguments z Matrix (2-D) containing the values to be plotted as a persp plot. colvar The variable used for coloring. or when shade is > 0 or lighting is TRUE). to mimic the behavior of persp. border The color of the lines drawn around the surface facets. lwd. shift. If col is NULL and colvar is not specified. Also allowed is to pass a list with arguments for the image2D function. co The defaults for the parameters are side = 4. theta gives the azimuthal direction and phi the colatitude. width = 1. and the axis parameters at. If col is NULL and colvar is specified. labels. If NA then the facets will be transparent. an image will be plotted at the bottom. y Vectors or matrices with x and y values. If colkey = NULL then a color key will be added only if col is a vector. width. dist = 0. Values of NULL. If present. If a vector. used for the color key. line. col Color palette to be used for the colvar variable. Setting colkey = list(plot = FALSE) will create room for the color key without drawing it. tick. This gives good results only if border is given a color. clim Only if colvar is specified. facets If TRUE. image If TRUE. NAcol Color to be used for NA values of colvar. no color key legend will be added. one value or a vector of two numbers. it should have the same dimension as z. The default is to draw the color key on side = 4. It is usually faster to draw with facets = FALSE. or FALSE will toggle off coloration according to colvar. NA. will disable the drawing of borders. NA. x. clab can be made a vector.e. dist. then col denotes the color of the surface facets. the label to be written on top of the color key. Finally. set colvar = NULL and make col a matrix of colors with (nrow(z)-1) rows and (ncol(z)-1) columns. if resfac equals 3 then for each adjacent pair of x.values respectively. then the surface facets are colored “white” and the border (if NA) will be colored as specified by col. or a list with parameters for the color key (legend). If FALSE. plot = TRUE. outer. If a matrix (only for persp3D). x should be of length equal to nrow(z) and y should be equal to ncol(z). For instance.col) will be used. List parameters should be one of side. in the right margin. Values of colvar that extend the range will be put to NA. lty. pos. plot. An optional parameter to this list is . then col will be grey. theta. default is “white”. the range of the color variable. then a red-yellow-blue colorscheme (jet. resfac Resolution factor. col. The label will be written at the same level as the main title. i. If resfac is one number then the resolution will be increased similarly in x and y-direction. to lower it. with the first values empty strings.clab.ticks. x and y should have the same dimension as z. addlines. The default. font. NULL (default). if colkey = FALSE. phi The angles defining the viewing direction.and y-values. A value > 1 will increase the resolution. See colkey. lwd. clab Only if colkey = TRUE. length = 1. colkey A logical. see persp. for the x and y. z will be interpolated to two intermediary points. This uses simple linear interpolation.

ltheta. 0. See example. "zmax". for ribbons parallel to the x. expan . If TRUE.. additional arguments passed to the plotting methods.9] (ribbon3D). a contour will be plotted at the bottom. either averaging the colvar (inttype = 1. The default is to put the image at the bottom. ylab. Either one number. Will overrule shade not equal to NA. curtain If TRUE. space The amount of space (as a fraction of the average bar/ribbon width) left between bars/ribbons. zlab. Allowed values for side are a zvalue.col. Only effective if the persp argument (box) equals TRUE (this is the default). The function should have as argument the transformation matrix (pmat).75 provide an approximation to daylight illumination. along The direction along which the ribbons are drawn. "zmax". sr and alpha. the default only drawing background panels.5 to 0. e. for positioning at bottom or top respectively. A value inbetween [0. See persp.. The following persp arguments can be specified: xlim. for the x. See persp. main. Also allowed is to pass a list with arguments for the contour function. 3 or extending the x.see details.and y.3-D perspectives 27 the side where the image should be plotted. This can be useful for drawing background grids or scatterplot smooths. shade the degree of shading of the surface facets. a plot is created. panel.direction. the surface is shaded as though it was being illuminated from the direction specified by azimuth ltheta and colatitude lphi. bty The type of the box. or side = "zmin". the figure looks like a net. zlim.1. z values (inttype = 2) . ylim. To switch on lighting. Values of shade close to one yield shading similar to a point light source model and values close to zero produce no shading. or side = "zmin". . "y" or "xy". the ribbon or persp edges will be draped till the bottom. then the surfaces will be added to the current plot. and colors may appear more bright. d. or a two-valued vector. images or contours drawn) but before any plotting takes place. See examples in jet. An optional parameter to this list is the side where the image should be plotted. specular. y.or both axes. If FALSE a new plot is started. In the latter case. r. 0. one of "x".first A function to be evaluated after the plot axes are set up (and if applicable. sub.y. contour If TRUE. scale. exponent.g. Values in the range 0. xlab. for positioning at bottom or top respectively. otherwise the viewing transformation matrix is returned (as invisible). See perspbox.9] (hist3D) or [0. lighting If not FALSE the facets will be illuminated. If TRUE (default). The default is to put the image at the bottom. add Logical. diffuse. inttype The interpolation type to create the polygons. it should be defined as function(pmat). lphi if finite values are specified for ltheta and lphi. the argument lighting should be either set to TRUE (using default settings) or it can be a list with specifications of one of the following: ambient. plot Logical. Allowed values for side are a zvalue.

. dDepth Parts of this help page come from the help pages of the R-core function persp. this is only effective is border is not NA. lwd can be specified. there are three interpolation schemes as set by inttype. When facets are colored. which is similar to inttype = 1 except for the NA values. The perspective plots are drawn as filled polygons. This will make the colors (and/or shading) smoother. i. lwd. To color the facets the x. i. This will tend to make the NA region larger. In addition. persp3D(z = volcano. when side = "z". use plotdev. The arguments after . Each polygon is defined by 4 corners and a color.e. which will be removed during the averaging. The viewing depth can be adjusted with argument dDepth. All objects will be plotted. the color values need to be of size (nx-1)(ny-1). . The default (inttype = 1) is similar to R’s function persp. the perspbox arguments col.axis. zlim only affect the axes.e. defined in its centre. This is mainly of use in case a colvar is defined. When inttype = 1 then NA values in colvar will be used as such during the averaging. In case a colvar is defined. . and averages are taken from the original data (nx and ny are number of x and y points). the viewing transformation matrix.. must be matched exactly. col. and it is not desirable that the colors are smoothened. its values are to be recalculated to the middle of each polygon. the viewing depth of the contour segments is artificially decreased.panel. the arguments lty. to increase the resolution in order to make smoother images. to toggle on or off facet coloration. . lwd. Note To make a contour to appear on top of an image. a second interpolation scheme is selected. This will make the z-values (topography) smoother than the original data. An alternative is to set inttype = 3. Details persp3D is an extension to the default persp plot that has the possibility to add a color key. it is assumed that the z values and colvar values are both defined in the centre of the polygons. z grid is extended (to a (nx+1)(ny+1) grid). This type of interpolation may be preferable for color variables that have NA values. Value Returns.grid can also be given a value. To select objects only within the axis limits. contour = list(side = "z".panel. This will tend to make the NA region smaller. e. as invisible.grid..28 3-D perspectives The arguments xlim.g. For all functions. while colvar is used as such. By setting inttype = 2. y. including those that fall out of these ranges. as taking averages tends to increase the NA region. In some cases this may produce slight artifacts. See trans3D. col. ylim. In this scheme. alpha can be given a value inbetween 0 and 1 to make colors transparent. and assumes that the z-values define the points on the corners of each polygon.

Chambers.5. "m")) # keep ratios between x. length = 0.axis = 0.par("mfrow") ## ======================================================================= ## Ribbon. J.3-D perspectives 29 Author(s) Karline Soetaert <karline. m". seq(1. R. (1988) The New S Language.. clab = "height. y = 1:ncol(volcano). by = 3). and Wilks. side = 2). See Also persp for the function on which this is based. persp3D(z = volcano. rotating a plot. Examples # save plotting parameters pm <. text3D for annotating axes (hist3D). x = 1: nrow(volcano).3. ] ribbon3D(z = Vy. no scaling.and y (scale = FALSE) # change ratio between x. length = 0. scale = FALSE.5. colkey = list(side = 1.axis = 0. A. clab = c("height". 2)) # simple. along = "y".8)) ## ======================================================================= ## Several ways to visualise 3-D data ## ======================================================================= . Wadsworth & Brooks/Cole.5. colkey = list(width = 0.volcano[seq(1. facets ## ======================================================================= par(mfrow = c(2.8. expand = 0. nrow(volcano).soetaert@nioz.3. color keys. expand = 0. plotdev for zooming. A. main = "volcano". rescaling. space = 0. main = "volcano". length = 0. ncol(volcano). in x--direction V <.3. colkey = list(width = 0. in y-direction Vy <.5. clab = "m") # ribbon. R. facets = FALSE. cex.nl> References The persp function on which this implementation is based: Becker.and z (expand) persp3D(z = volcano. cex.5)) # ribbon. Hypsometry for an example where axis-panels are colored. by = 3)] # lower resolution ribbon3D(z = V. persp. M.volcano[. scatter3D for a combination of a persp surface and data points.

with (mesh(x. col = "red"). length. 0. ncol(volcano). x = x. 2)) persp3D(z = Volcano. z. x = x.seq(1. image = list(col = grey (seq(0. facets = FALSE. by = 0.y <. colvar = cv) # takes averages of z persp3D(x. image = TRUE) persp3D(z = Volcano. space = 0. zlim= c(-100. image = list(side = 350)) ## ======================================================================= ## Use of inttype ## ======================================================================= par(mfrow = c(2. x = x. y = y. 400). y. contour = list(side = c("zmin".mesh(x.5*runif(100)) persp3D(x.with(grid. 1. cos(x) *sin(y)) + runif(100) cv <. contour = TRUE. scale = FALSE.3) hist3D(z = z. 200). expand = 0. inttype = 2) # takes averages of colvar . zlim= c(-200. "350")).2)) persp3D(z = z. nrow(volcano). y = y. inttype = 2.2.3) grid <.volcano [x.30 3-D perspectives x <.out = 10) z <.2) y <. y = y) persp3D(z = z.seq(1. y. 2)) x <. border = "black") ## ======================================================================= ## Contours and images added ## ======================================================================= par(mfrow = c(2. by = 3) Volcano <.5. by = 3) y <.seq(-pi. phi = 20.seq(-pi. "z".matrix(nrow = 10. x = x. contour = list(nlevels = 20. 200). colkey = FALSE) x <. 2*pi. length. pi. y = y. pi.out = 100)))) persp3D(z = Volcano. colvar = cv. shade = 0. zlim = c(-200.seq(0. shade = 0. x = x. colkey = FALSE) persp3D(z = Volcano. y) z <. along = "xy". 200). by = 0. y = y. image = FALSE) persp3D(z = Volcano. z. curtain = TRUE) # ribbons in two directions and larger spaces ribbon3D(z = z. y). zlim = c(-100. y] ribbon3D(z = Volcano.5. contour = TRUE. cos(x) * sin(y)) par(mfrow = c(2.

colvar = V2.volcano[10:15. colvar = V2. inttype = 2.2.col(100)) . border = "black". panel. y = rep(1. XY1$y. pmat = trans) lines(XY.first = panelfirst.function(trans) { zticks <.trans3D(x = rep(1.3. theta = 0. phi = 20. col = "blue". colkey = FALSE) ## ======================================================================= ## with / without colvar / facets ## ======================================================================= par(mfrow = c(2. 87).NA V2[4.NA image2D(V2.trans3D(x = 1:87. pmat = trans) XY1 <. including NAs. 10:15] V2[3:4. scale = FALSE. y = rep(61.seq(100. colvar = V2. 1)) # A function that is called after the axes were drawn panelfirst <. XY0$y. 3:4] <. z = rm. y = rep(ncol(volcano). main = "inttype = 3") ## ======================================================================= ## Use of panel.first ## ======================================================================= par(mfrow = c(1. theta = 0. main = "inttype = 2") # average of V2. phi = 20.3-D perspectives 31 ## ======================================================================= ## Use of inttype with NAs ## ======================================================================= par(mfrow = c(2. y = 1: 61. col = gg. by = 20) len <. len). 2)) persp3D(z = volcano. theta = 0. NAs unaffected persp3D(z = VV. z = zticks. 2)) VV <. border = "black". len). NA region larger persp3D(z = VV.rowMeans(volcano) XY <. NA region smaller persp3D(z = VV. border = "black") # shows true NA region # averages of V2. z = zticks. ignoring NA. pmat = trans) segments(XY0$x.length(zticks) XY0 <. inttype = 1. expand = 0. theta = 10. x = 1:87. 5] <. len). lty = 2) rm <. lwd = 2) } persp3D(z = volcano. inttype = 3. shade = 0. len). phi = 20.trans3D(x = rep(1.V2 <. 180. border = "black". main = "inttype = 1") # extension of VV. XY1$x.

1)) clim <. plot = FALSE) persp3D(z = volcano + 400. shade = 0. ncol = 61. length.matrix(ncol = 87. expand = 0. data = seq(0. expand = 0. nrow = 61. col = "grey". byrow = TRUE. clim = clim. scale = FALSE.3).01. colkey = FALSE. seq(1. alpha = 0.matrix(nrow = 87. lphi = 90) persp3D(z = volcano. 15)] hist3D(z = VV. data = 1:61) volcy <.. col = jet.and y-coordinates of 'volcano' volcx <. bty = "b2") # this also works: # persp3D(z = volcano. scale = FALSE. data = seq(0.01.01. colvar = NULL. 87.t(volcy + matrix(ncol = 87. expand = 0. box = FALSE.32 3-D perspectives # shiny colors . 15. facets = NA) ## ======================================================================= . clim = clim. scale = FALSE.col(100.volcano[seq(1. 61. ncol = 61. x = volcx.3) # tilted x.01) # transparent colors hist3D(z = VV. border = "black") hist3D(z = VV. colkey = FALSE) # plot = TRUE by default ## ======================================================================= ## hist3D ## ======================================================================= par(mfrow = c(2.volcx + matrix(nrow = 87. colvar = volcano. 600).3. lighting = TRUE.set lphi for more brightness persp3D(z = volcano. add = TRUE.. data = 1:87) volcx <. plot = FALSE) persp3D(z = volcano + 200. add = TRUE. facets = FALSE. colvar = volcano. 2)) VV <. nrow = 61. phi = 80) ## ======================================================================= ## Several persps on one plot ## ======================================================================= par(mfrow = c(1.out = 87))) persp3D(volcano. scale = FALSE. col = "lightblue".range(volcano) persp3D(z = volcano. shade = 0. lwd = 2) hist3D(z = VV. clim = clim. expand = 0. 15). y = volcy.out = 61)) volcy <. 15. byrow = TRUE. length. zlim = c(100.

183). col = jet. bty = "g". 1)) x <. col = "#0072B2".. . y = 1. shade = 0.7. ticktype = "detailed". border = "black". ylim = c(-0. 1.. breaks = 15) hist3D(x = hs$mids. scale = FALSE. facets = TRUE. ltheta = 50. expand = 0. 2)) hist3D(z = VV. space = 0.2. shade = 0. bty = "g". ltheta = 90.3.01. d = 2) # extending the ranges plotdev(xlim = c(-0. curtain = TRUE) ribbon3D(z = VV.2.3. NAcol = "white". phi = 20.hist(x. phi = 20. border = "black". panel. expand = 20. bty = "g". colkey = NULL. bty = "g".3-D surfaces 33 ## hist3D and ribbon3D with greyish background. zlim = c(95. ylim = c(0. df = 4) hs <.01. ## ======================================================================= par(mfrow = c(2. scale = FALSE. theta = 40. 1. ticktype = "detailed". ltheta = 90. colvar = z. space = 0. border = NA. rotated. rescaled. theta = 20. ticktype = "detailed". d = 2. 2. expand = 0.col(100).2. col = "white". z. . scale = FALSE. data = hs$density).. spheresurf3D plots a colored image on a sphere. lighting = TRUE... Usage surf3D (x. shade = 0..01. y. theta = 45) ribbon3D(z = VV. main = "3-D perspective") # reset plotting parameters par(mfrow = pm) 3-D surfaces Functions for plotting 3 dimensional shapes Description surf3D plots a surface in 3-D with a color variable. phi = 20. col = "lightblue".2. border = "black"..0). scale = FALSE.3. z = matrix(ncol = 1.2). space = 0. d = 2. space = 0. along = "y".first = NULL. curtain = TRUE) ## ======================================================================= ## hist3D for a 1-D data set ## ======================================================================= par(mfrow = c(2. col = "lightblue".rchisq(1000.2).1. expand = 0. phi = 40. phi = 20.

will disable the drawing of borders. unless x. They should be of the same dimension as colvar. no color key legend will be added.col) will be used. pos. inttype = 1. theta gives the azimuthal direction and phi the colatitude. col Color palette to be used for coloring the colvar variable. ltheta = -135. It is usually faster to draw with facets = FALSE. For instance. shade = NA. y. then a red-yellow-blue colorscheme (jet. bty = "n". data = 1:50. co The defaults for the parameters are side = 4. If NA then the facets will be transparent. List parameters should be one of side.. If FALSE. y. If a matrix.. col. colkey = NULL. then col will be "grey". theta = 0. for the x and y. or a list with parameters for the color key (legend). lighting = FALSE. facets = TRUE. y and z-values that define the surfaces to be colored. NAcol Colors to be used for colvar values that are NA.34 3-D surfaces clim = NULL. z. then a contour plot will be added to the image plot. shade = NA. dist = 0. length. NA. z Matrices with x. lighting = FALSE. Also allowed is to pass a list with arguments for the contour function. then the surface facets are colored “white” and the border (if NA) will be colored as specified by col. y are a matrix. clab = NULL. If col is NULL and colvar is not specified. full = FALSE. width = 1. resfac Resolution factor. font. If col is NULL and colvar is specified. bty = "n". facets If TRUE. NULL (default). dist. tick. length = 1. This gives good results only if border is given a color or a shade is used. plot = TRUE. width. A value > 1 will increase the resolution. line. . theta. border = NA. or FALSE will toggle off coloration according to colvar. plot = TRUE) spheresurf3D (colvar = matrix(nrow = 50. plot = TRUE) Arguments x. ncol = 50. and the axis parameters at. shift. then col denotes the color of the surface facets. phi the angles defining the viewing direction. If colkey = NULL then a color key will be added only if col is a vector. if resfac . clim = NULL. col = jet. lty. lphi = 0. The default.. See colkey. add = FALSE. i. outer. resfac = 1.e. lwd. contour If TRUE.values respectively. colvar The variable used for coloring. in the right margin. panel. NAcol = "white". clab = NULL. see persp. Values of NULL. if colkey = FALSE. lphi = 0.clab. Setting colkey = list(plot = FALSE) will create room for the color key without drawing it.ticks. NA. byrow = TRUE). inttype = 1. lwd. contour = FALSE. it should be of the same dimension as x. phi = 0. labels. colkey A logical. border The color of the lines drawn around the surface facets.col(100). addlines. The default is to draw the color key on side = 4.first = NULL. one value or a vector of two numbers. add = FALSE. ltheta = -135. plot.

Logical. The function should have as argument the transformation matrix. d. either taking the mean of the colvar variable (inttype = 1.axis. z will be interpolated to two intermediary points.5 to 0. Values in the range 0. 35 equals 3 then for each adjacent pair of x. the default is to draw no box. . This can be useful for drawing background grids or scatterplot smooths. diffuse. y. To switch on lighting. Only if colkey is not NULL or FALSE. The interpolation type to create the polygons. All objects will be plotted. See example of persp3D and last example of voxel3D. this will tend to make the NA region smaller.grid can also be given a value.. col.panel. must be matched exactly.. e. The arguments after . See persp. Values 1. exponent.col.3-D surfaces panel. used for the color key. Logical. The type of the box. If TRUE. If FALSE a new plot is started. NAs are removed before taking averages. the perspbox arguments col. with the first values empty strings. the degree of shading of the surface facets. ylim. Logical. If not FALSE the facets will be illuminated. main. it should be defined as function(pmat). lphi inttype full add plot . z values (inttype = 2). This uses simple linear interpolation. See persp. the label to be written on top of the color key. A function to be evaluated after the plot axes are set up but before any plotting takes place. including the invisible part. Additional arguments passed to the plotting methods. See perspbox. The following persp arguments can be specified: xlim.g. Will overrule shade not equal to NA. The label will be written at the same level as the main title. Values of shade close to one yield shading similar to a point light source model and values close to zero produce no shading. the argument lighting should be either set to TRUE (using default settings) or it can be a list with specifications of one of the following: ambient.75 provide an approximation to daylight illumination. expan The arguments xlim. Values of colvar that extend the range will be put to NA. if finite values are specified for ltheta and lphi. otherwise the viewing transformation matrix is returned (as invisible).grid. 3 or extending the x. If TRUE. the range of the color variable. In addition.and y-values. zlim only affect the axes. specular. a plot is created. . sub. If resfac is one number then the resolution will be increased similarly in x and y-direction. To lower it. xlab. See details and an example in persp3D. including those that fall out of these ranges. For inttype = 3. scale. lwd. NAs are included when inttype = 1. use plotdev. zlim. ylim. sr and alpha. ylab. then the surfaces will be added to the current plot. r. col. See examples in jet. . and colors may appear more bright. Only if colvar is specified.first clab clim bty lighting shade ltheta.panel. To select objects only within the axis limits. clab can be made a vector. 3 differ in how they treat NAs in the colvar variable. If FALSE only the visible half will be drawn (faster). the full sphere will be drawn. zlab. If TRUE (default). This will tend to make the NA region larger. the surface is shaded as though it was being illuminated from the direction specified by azimuth ltheta and colatitude lphi. lwd.

y.nl> See Also persp for the function on which this implementation is based. z. plotdev for zooming. This means that the x. . box = FALSE. See trans3D.r * sin(phi) * cos(theta) y <.col.r * sin(phi) * sin(theta) # full colored image surf3D(x.mesh(X. y. length. y and z grids r <. rescaling. shade = 0.seq(0. box = FALSE. rotating a plot.r * cos(phi) z <.out = 50) M <. pi. jet.out = 50) Y <.sin(4*phi)^3 + cos(2*phi)^3 + sin(6*theta)^2 + cos(6*theta)^4 x <.36 3-D surfaces Details Function spheresurf3D is a projection on a sphere with radius 1. colkey = FALSE. 1)) ## ## ## ## ======================================================================= A three-dimensional shape (ala http://docs. 1. 2*pi. colkey = FALSE.5. theta = 60) # same.M$y # x.par("mfrow") pmar <. z. Y) phi <. colvar = y. Examples # save plotting parameters pm <. plotdev for other examples of surf3D. colvar = y.enthought. Author(s) Karline Soetaert <karline.par("mar") par(mar = c(1. but just facets surf3D(x. length. 1.seq(0. 2)) # create grid matrices X <.M$x theta <.y.com/mayavi/mayavi/mlab. 1].and zaxes range from [-1.html) ======================================================================= par(mfrow = c(2. Value Returns the viewing transformation matrix.soetaert@nioz.

y and z. 2*pi.mesh(seq(0.info/surface/gallery.(3 + cos(v/2)*sin(u) .sin(v/2)*sin(2*u))*sin(v) z <. box = FALSE. theta = 60. seq(0.out = 50). box = FALSE.8) # Now with one color and shading surf3D(x. length. seq(pi/3. 2*pi. AND increasing the size # (by reducing the x.sin(v/2)*sin(u) + cos(v/2)*sin(2*u) . 6*pi.u/2 * sin(v) * sin(u) z <.sin(u) <. colkey = FALSE. 2)) # Shape 1 M <.8.M$y x <.3-D surfaces 37 theta = 60. z. by = 10)) plotdev(theta = angle) ## End(Not run) ## ## ## ## ======================================================================= Several other shapes http://xahlee. colvar = y. length. colkey = FALSE. 360. colvar = z. y.M$y x y z <. colkey = FALSE) # shape 3: uses same mesh. length. other perspective (d >1) x <. box = FALSE.html ======================================================================= par(mfrow = c(2. zlim = range(z)*0.(3 + cos(v/2)*sin(u) .u/2 * cos(v) surf3D(x.M$x . z.M$x .ranges surf3D(x.9) ## Not run: # rotation for (angle in seq(0.u/2 * sin(v) * cos(u) y <.out = 50)) u <. phi = 50) # Shape 2: add border M <. y. z. xlim = range(x)*0. pi.8. v <.sin(v) <. y.mesh(seq(0. y.sin(v/2)*sin(2*u))*cos(v) y <. length. theta = 60.sin(u + v) surf3D(x. shade = 0. colvar = z.out = 50). v <. border = "black". col = "lightblue". ylim = range(y)*0.out = 50)) u <. border = "black". z. facets = FALSE) # with colors and border.

cos(u)*sin(v) y <. box = FALSE) box() ## ======================================================================= ## A sphere.out = 50). z. pi. length. 2)) spheresurf3D() # true ranges are [-1. 2.1 .8] to make larger plots lim <. 1)) M <.sin(u*6) * sin(v*6) surf3D(y. x. z. v <.2. y. colvar = sqrt(x + 8. border = "black".M$y x <. xlim = lim.mesh(seq(-13. w <.mesh(seq(0. theta = 10. v <. facets = FALSE) # shape 4: more complex colvar M <. 0.cos(v) colvar <. d = 2.out = 50)) u <. 2*pi. 0.8) spheresurf3D(colkey = FALSE. ltheta = 40) ## ======================================================================= ## Function spheresurf3D ## ======================================================================= par(mfrow = c(2.M$x . 2. 1]. colkey = FALSE. length.38 3-D surfaces surf3D(x.M$x . seq(-37.out = 50). set limits to [-0. 13. seq(0.sqrt(r) b*((w*cosh(b*u))^2 + (b*sin(w*v))^2) -u + (2*r*cosh(b*u)*sinh(b*u)) / D (2*w*cosh(b*u)*(-(w*cos(v)*cos(w*v)) . ylim = lim. zlim = lim) spheresurf3D(bty = "b". bty = "b2".8.c(-0.4. with box type with grid lines ## ======================================================================= par(mar = c(2.M$y b D x y z <<<<<- 0. length. r <.3). y.out = 50)) u <. data = runif(900))) ## ======================================================================= ## Images on a sphere ## ======================================================================= .2. z.4. 2)) par(mfrow = c(1.sin(u)*sin(v) z <.8. 37.sin(v)*sin(w*v))) / D (2*w*cosh(b*u)*(-(w*sin(v)*cos(w*v)) + cos(v)*sin(w*v))) / D surf3D(x. phi = 50) spheresurf3D(colvar = matrix(nrow = 30. ticktype = "detailed".b^2. phi = 0. colkey = FALSE. colvar = z. lighting = TRUE.4. colvar = colvar. length.

voxel3D plots isosurfaces as scatterpoints.Hypsometry$z. colkey = NULL. phi = 40. y. theta = 90. colkey = NULL. theta = 40.c(-0.3-D volume visualisation 39 par(mfrow = c(1. add = FALSE. plot = TRUE) slicecont3D (x. lighting = FALSE. Its output can be plotted with triangle3D. zs = NULL. colvar. ys = max(y). z. log = "c") # restore plotting parameters par(mfrow = pm) par(mar = pmar) 3-D volume visualisation Functions for plotting 3-D volumetric data. ltheta = -135. col = jet. isosurf3D plots isosurfaces from a 3-D dataset. panel. AA[AA<=0] <. ylim = lim. NAcol = "white". mar = c(1. facets = TRUE. xs = NULL.col(100). phi = 30. ys = NULL.8) # log transformation of color variable spheresurf3D(AA... xlim = lim... . xs = min(x). shade = NA. level = NULL. y. y. Description slice3D plots a 3-D dataset with a color variable as slices or on surfaces. 0. Its output can be plotted with scatter3D. NAcol = "white".col(100). z) points from volumetric data. createvoxel creates voxels (x. . clab = NULL. 3)) AA <. 1. border = NA. zlim = lim.NA lim <. clim = NULL. theta = 40.first = NULL. NAcol = "black". slicecont3D plots a 3-D dataset with a color variable as contours on slices. Usage slice3D (x. bty = "b".8. box = FALSE. 1. col = jet. facets = TRUE. 1). panel... colvar. . border = NA. zs = min(z). phi = 40.first = NULL. createisosurf create the isosurfaces (triangulations) from volumetric data. lphi = 0. z.

clab = NULL. phi = 40. operator = "=". theta = 40.first = NULL. colvar. plot = TRUE) createisosurf (x. bty = "b". plot = TRUE) voxel3D (x. lphi = 0.first = NULL. y.rm = TRUE). z.5. ltheta = -135.40 3-D volume visualisation clim = NULL.. For triangle3D. colvar. second and third dimension of colvar respectively. tri A three-columned matrix (x. bty = "b". add = FALSE. clim = NULL.5. length(y). length(z)). level = mean(colvar. = mean(colvar.01. z. NAcol Colors to be used for colvar values that are NA. phi the angles defining the viewing direction.. z Vectors with x. colvar. y. plot = TRUE) isosurf3D (x. . theta = 40. col Colors to be used for coloring the colvar variable. . shade = 0. facets = TRUE. colvar. level = mean(colvar. colkey = NULL. colvar The variable used for coloring. theta = 40. dDepth = 0.rm = TRUE)) createvoxel (x. y and z-values.first = NULL. col = NULL. z. colvar should be of length = nrow(tri) / 3. border = NA.. add = FALSE. add = FALSE. border = NA. na. theta. plot = TRUE) triangle3D (tri. isofunc A function defined as function(x. If col is NULL then a redyellow-blue colorscheme (jet. y. col = NULL. lighting = FALSE.col) will be used. clab = NULL. clab = NULL. z) with triangle coordinates.. shade = 0. and that returns the three-columned matrix with triangle coordinates. isofunc = createisosurf. NAcol = "white". createisosurf uses function computeContour3d from package misc3d.. y. It must be present. panel.. phi = 40. lphi = 0. ltheta = -135. colkey = NULL.01. eps = 0. bty = "b".. phi = 40. panel. operator = "=") Arguments x. z. y. eps = 0. level col = bty = z. na. A triangle is defined by three consecutive rows. colvar = NULL. facets = TRUE. It should be an array of dimension equal to c(length(x).. y. add = FALSE. na.rm = TRUE). "b". jet. .rm = TRUE).col(100). colvar. lighting = FALSE. na. The default. theta gives the azimuthal direction and phi the colatitude.. level). see persp. . level = mean(colvar. They should be of length equal to the first. panel. y.

the range of the color variable. the argument lighting should be either set to TRUE (using default settings) or it can be a list with specifications of one of the following: ambient. co The defaults for the parameters are side = 4. col. To lower it. level should either be one number (if operator equals '='. line. outer.ticks. See colkey. no color key legend will be added. zs Vectors or matrices. it should be defined as function(pmat). clab Only if colkey is not NULL or FALSE. shift. Matrices specify a surface on which the colvar will be projected. in the right margin. lwd. addlines. will disable the drawing of borders. See persp. with the first values empty strings. dist. Values of shade close to one yield shading similar to a point light source model and values close to zero produce no shading. clim Only if colvar is specified. The function should have as argument the transformation matrix. To switch on lighting. length. NULL (default). Vectors specify the positions in x. width. If NA then the facets will be transparent. shade the degree of shading of the surface facets. xs. See last example and example of persp3D. sr and alpha.75 provide an approximation to daylight illumination. labels. ys. The default. i. colkey A logical. facets If TRUE. diffuse. The values of colvar will be projected on these slices. the use of multiple values may need transparent colors to visualise. then the surface facets are colored “white” and the border (if NA) will be colored as specified by col. exponent. Will overrule shade not equal to NA. lwd. Values in the range 0.col.clab. font. There can be more than one level. or a list with parameters for the color key (legend). If colkey = NULL then a color key will be added only if col is a vector. if colkey = FALSE. The default is to draw the color key on side = 4. width = 1. If FALSE.e. and the axis parameters at. lighting If not FALSE the facets will be illuminated. pos. It is usually faster to draw with facets = FALSE. This can be useful for drawing background grids or scatterplot smooths. used for the color key. e.3-D volume visualisation 41 border The color of the lines drawn around the surface facets. tick. '<'. For isosurf3D. . clab can be made a vector.g. Values of colvar that extend the range will be put to NA. and colors may appear more bright. level The level(s) at which the contour will be generated or the isosurfaces generated. The label will be written at the same level as the main title. Setting colkey = list(plot = FALSE) will create room for the color key without drawing it. length = 1. NA. lty. dist = 0. and one is often best. plot. but for slicecont3D too many will give a crowded view.first A function to be evaluated after the plot axes are set up but before any plotting takes place. panel.5 to 0. List parameters should be one of side. For voxel3D. '>') or two numbers (for operator = '<>'). then col denotes the color of the surface facets. the label to be written on top of the color key. See examples in jet. specular. y or z where the slices (planes) are to be drawn. plot = TRUE.

’<’. must be matched exactly. zlim. coloring is always according to the z-variable. larger or smaller than the required level or to be within an interval. then the slices. lwd can be specified. the image polygons may hide some contour segments. If FALSE a new plot is started. A point is selected if it closer than eps*diff(range(colvar)) to the required level. col. lwd. Please cite the package misc3d (Feng & Tierney. Only effective if the persp argument (box) equals TRUE (this is the default). lphi if finite values are specified for ltheta and lphi. ’>’. See perspbox. ’<>’ for selection of points ‘equal’ (within precision). One triangle is defined by three consecutive rows. A more flexible coloration can be achieved by using createvoxel. In addition. See persp. the default only draws background panels. z defining the points that are at a distance of less than eps*diff(range(colvar)) from the required level. y. If TRUE. the viewing depth of the segments can be artificially decreased with the factor dDepth times the persp argument expand (usually = 1). col.axis. zlab. add Logical.42 3-D volume visualisation ltheta. For all functions. xlab. . dDepth When a contour is added on an image. All objects will be plotted. operator One of ’=’. the perspbox arguments col. plot Logical. To avoid that. alpha can be given a value inbetween 0 and 1 to make colors transparent. followed by scatter3D. use plotdev. ylim. only used when operator = "=". additional arguments passed to the plotting methods.. voxels or surfaces will be added to the current plot.grid can also be given a value.panel. Function createvoxel returns a list with the elements x. including those that fall out of these ranges. otherwise the viewing transformation matrix is returned (as invisible).grid. See contour3D. The following persp arguments can be specified: xlim. sub. . For voxel3D. ylab. which is based on the marching cubes algorithm. See trans3D. . Too large values of dDepth may create visible artifacts. to make them appear in front of the polygons. eps The voxel precision. The arguments xlim. See examples. If TRUE (default). the arguments lty. a plot is created. 2008) when using isosurf3D. The arguments after ..panel. Value The plotting functions return the viewing transformation matrix. ylim. Its output can be plotted with scatter3D. y. z) with triangle coordinates. main. To select objects only within the axis limits. the surface is shaded as though it was being illuminated from the direction specified by azimuth ltheta and colatitude lphi. from package misc3d. zlim only affect the axes. Function createisosurf returns a three-columned matrix (x. lwd. . Note The isosurf3D function uses function computeContour3d. It can be plotted with triangle3D. bty The type of the box.

ys = c(-1. W. Marching Cubes: a high resolution 3D surface reconstruction algorithm. y.par("mfrow") pmar <.seq(-1.y^2 . URL http://www.5. y. -0. 1987.org/v28/i01/. Computing and Displaying Isosurfaces in R. zs = c(-1. y.E. y. plotdev for zooming. phi = 40) ## ======================================================================= ## coloring on a surface ## ======================================================================= XY <. Computer Graphics. Vol. 4.. 0. H. xs = XY$x. 1).jstatsoft.E. z. 2008. colvar = colvar. ys = XY$y.soetaert@nioz. See Also Oxsat for another example of slice3D.par("mar") ## ======================================================================= ## Simple slice3D examples ## ======================================================================= par(mfrow x <. by = 0. colvar = colvar. 0). z.mesh(x.z^2)) # default is just the panels slice3D (x.y <grid <colvar <- = c(2. pp 163-169 (Proc. border = "black") slice3D (x.1) mesh(x. colvar = colvar. rotating a plot.5). theta = 60) # contour slices slicecont3D (x. ys = seq(-1. lphi = 90. x*exp(-x^2 . z. y. z.5). 1. by = 0.3-D volume visualisation 43 Author(s) Karline Soetaert <karline. Luke Tierney. rescaling. z) with(grid. ltheta = 0) ## ======================================================================= . No.XY$x*XY$y slice3D (x. of SIGGRAPH). theta = 60. xs = c(-1. zs = ZZ. 0. 1. colvar = colvar. theta = 60. 21. Examples # save plotting parameters pm <. and Cline. y) ZZ <. 2)) z <. Journal of Statistical Software 28(1). lighting = TRUE.nl> References Lorensen. Dai Feng.

length.z <. xs = 0.alpha = 0. xs = c(-4. 4). NAcol = "black". z) R <.out = 15) xyz <. y. lphi = 0. by = 2). y. shade = NA) # three levels. 0. 4. d = 2) ## End(Not run) slice3D(x. theta = 0. z. ltheta = 0. ys = c(-4.2) M <. Oxsat$lat > .2 isosurf3D(x.y <. zs = NULL. 2. 4). colvar = p.5). phi = 45) ## ======================================================================= ## isosurf3D example .seq(-4. alpha = 0. F. z. colvar = p. shade = 0. lighting = TRUE. ] slice3D(x = Oxsat$lon.2. y. z) F <. level = 2. 0)) ## ======================================================================= ## A section along a transect ## ======================================================================= data(Oxsat) Ox <.with(xyz. 2). by = 0. colvar = Ox.z <. y = 1:5. col = "yellow". F. mar = c(2. 2. ys = 1:5. z = -Oxsat$depth. transparency added isosurf3D(x. z. y. lighting = TRUE) . level = 1. F. col = "blue". "blue". theta = 45. 4. z. log(x^2 + y^2 + z^2 + 10*(x^2 + y^2) * (y^2 + z^2) ^2)) # use shading for level = 1 .mesh(x.4. col = c("red".with (M. 2.sin(2*R) /(R+1e-3) ## Not run: # This is very slow .rather slow ## ======================================================================= par(mfrow = c(2.5 makes it transparent slice3D(x.9. 0. zs = NULL. zs = c(-4.Oxsat$val[. z.5 & Oxsat$lat < 5. ys = c(-4. clab = "F". 1)) x <. col = jet. y. y. level = seq(0. y.seq(-2. d = 2. "yellow"). 0). border = "black".col(alpha = 0. expand = 0.mesh(x. sqrt(x^2 + y^2 + z^2)) p <.y <.44 3-D volume visualisation ## Specifying transparent colors ## ======================================================================= par(mfrow = c(1.show triangulation with border isosurf3D(x. theta = 60. 2)) x <. border = "orange") # lighting for level .

y. alpha = 0. col = c("red". theta = 0) ## End(Not run) # use of creatisosurf iso <. theta = 0) ## End(Not run) ## ======================================================================= ## voxel3D example ## ======================================================================= par(mfrow = c(2. log(x^2 + y^2 + z^2 + 10*(x^2 + y^2) * (y^2 + z^2) ^2)) voxel3D(x. y. level = 2) head(iso) triangle3D(iso. phi = 0) plotdev(theta = 90. 2). colvar = vox$y.createvoxel(x.with(xyz. z. 4. vox$y. "blue".". y. "yellow").3) ## Not run: # higher resolution x <.out = 70) xyz <.with(xyz. col = "green".2. . F. z) F <. z) F <.z <. 2.more flexible for coloring vox <. level = 4) scatter3D(vox$x. level = 4.y <. alpha = 0. col = c("red". shade = NA. F. plot = FALSE. F. length.2. 2)) # fast but needs high resolution grid x <. 2. z. pch = ". shade = 0. length. z. y. z.mesh(x.mesh(x. y. 4. cex = 5) ## ======================================================================= ## rotation ## ======================================================================= plotdev(theta = 45.3-D volume visualisation 45 # transparency can also be added afterwards with plotdev() ## Not run: isosurf3D(x. clab = "F") plotdev(lighting = TRUE. level = seq(0. clab = "F") plotdev(lighting = TRUE. y. plot = FALSE. 2. z. phi = 10) # same using createvoxel . F. mar = c(2. F.seq(-2.y <. vox$z. by = 2). by = 2).createisosurf(x. y.out = 50) xyz <.seq(-2. "blue". 2. log(x^2 + y^2 + z^2 + 10*(x^2 + y^2) * (y^2 + z^2) ^2)) # three levels isosurf3D(x. "yellow").z <. level = seq(0. shade = NA.

phi = 20. data = xy$y) Bat <.na(Bat)] <. y = as.1 image2D(x = x. Hypox$y. . y = y.length(Oxsat$lon) Ny <.first = panel.out = Nx*Ny)) x <. Oxsat$lat) xy <. col. ncol = Ny.Oxsat$val[. Bat[!is.vector(M$y). operator = "<") panel <.clab = NULL. panel. length = 1.box = NULL. add = FALSE.clab = NULL. adj.vector(M$x). col = "grey". col. zlim = c(-1000. outer = FALSE.createvoxel(Oxsat$lon. xlim = range(Oxsat$lon). dist = 0. ticktype = "detailed". -Hypox$z. NAcol = "black". cex.mesh(Oxsat$lon. line = NA. colkey = FALSE) ## ======================================================================= ## voxel3D to show hypox sites ## ======================================================================= par(mfrow = c(1. col. lwd. Oxsat$val[.. lwd = 1.clab = NULL. side. shift = 0. pch = ". width = 1. either to an existing plot or starting a new plot.matrix(nrow = Nx. ylim = range(Oxsat$lat) ) # restore plotting parameters par(mfrow = pm) par(mar = pmar) Color key legend Plots a color legend Description colkey plots a color legend. x = as.trans3D(pmat = pmat. at = NULL.clab = NULL.46 Color key legend bty = "g".length(Oxsat$lat) M <. ncol = Ny. Usage colkey (col = NULL. length.clab = NULL. lty = 1. data = xy$x) y <. theta = 30.matrix(nrow = Nx. font = NA. add = TRUE. labels = TRUE. pos = NA. tick = TRUE. mar = c(2.axis = NULL.. addlines = FALSE.0).ticks = NULL. 2)) Hypox <.clab = NULL. 2. z = Bat. side = 4. col. Oxsat$lat. colvar = Hypox$cv. Oxsat$depth[1:19].1:19]. level = 40. 2. clim. font.1]. clab = NULL. bty = "b".ticks = 1.function(pmat) { # an image at the bottom Nx <. clog = FALSE. 1). line. colkey = FALSE) } scatter3D(Hypox$x.". z = rep(-1000.

05].clab The font of the colorkey title.clab The numer of lines in the margin where the colorkey title is to be drawn. used in the color key. it is at line. The label will be written at the same level as the main title. lty.ticks.clab =1. side Where to put the color key. Reasonable range is [-0. Positive values are upward when side = 2 or 4. If FALSE a new plot will be started and the color key will be positioned in the centre. Values of 1. then values of the color key will be log transformed. addlines If TRUE. mgp. 1 = same length as the axis. 4 will put the colorkey label at bottom. Alternatively. shift Shift relative to the centre. col. the color key will be added to the current plot and positioned in the margin.clab The size of the label written on top of the color key. hadj. tick.e. col. width Relative width of the color key. las = NULL) Arguments col Colors to be used for the color key. will draw lines inbetween the colors. 4 = right. pos.axis. If unspecified. padj. The default is to put it central. tcl = NULL. add If TRUE. side = 3.Color key legend 47 hadj = NA.75. the axis label and the axis ticks. clog If TRUE. lwd.5. . default = same as main title. cex. dist Distance of the color key to the margin. labels. i. left and right of the key respectively. then a red-yellow-blue colorscheme (jet. with the first values empty strings.box.axis. If col is NULL. and to the right for side = 1 or 3.clab The color of the label written on top of the color key. line. padj = NA. lwd Additional parameters as from the axis command. negative values cause the color key to be positioned closer to or within the main plot. col. length Relative length of the color key. tcl. tck.clab The adjustment of the colorkey title. adj.2. outer. either clab can be made a vector. cex. Positive values are further into the margin. line. mgp = NULL.clab.ticks Additional parameters to set the color of the color legend framing box.col) will be used. tck = NULL. The default is to put it central. It does not make sense to use this argument if length = 1. To lower it.axis").clab The side of the label written on top of the color key. 0. col. clab The label to be written on top of the color key.axis = par("cex. a number inbetween 0 (left) to 1 (right). at. font.2]. clim The range of the color values. las Additional parameters as from the axis command. 2 = left. a number inbetween 0 (left) to 1 (right). default = same as main title. 2. 1 = bottom. font. 3 = top. Reasonable range is [-0. cex. default = same as axis labels. side. it can be lowered by argument line. 0.

width = 0. add = FALSE. lwd = 3.1. clab = c("a". colkey = NULL: adds colkey because multiple colors image2D(z = volcano) # default. add = TRUE) # 'dist' to put colkey within the image # 'shift' to position colkey to the right or upward .clab = 2. colkey = list(plot = FALSE.clab = 0) colkey(side = 2. clim = range(volcano). width = 0.5.clab = 1)) colkey(side = 3. length = 0.clab = 1. clab = "z". line. clim = range(volcano)) ## ======================================================================= ## colorkey in new plot ## ======================================================================= colkey(side = 1.par(mar = c(5.soetaert@nioz. add = TRUE. line. colkey = FALSE) # colkey = list(plot = FALSE): no color key. clab = "a very long title in bold and close to the key"."c". adj. clab = "m".par(mfrow = c(2. 4. 1).1.nl> Examples # save plotting parameters pm <. side = 3)) colkey (side = 3. 1)) image2D(volcano. 2.clab = 5) colkey(side = 4. clim = c(1e-6. 1).5. clog = TRUE.1)) ## ======================================================================= ## colorkey as argument of a plot3D function ## ======================================================================= # default. extra space foreseen image2D(z = volcano. contour = TRUE) # colkey = FALSE: no color key. 1). line.48 Color key legend Author(s) Karline Soetaert <karline."d"). clim = c(0."b". clim = c(0. 4.5. side. col. clim = c(0. colkey = NULL: no colkey because only one color image2D(z = volcano. no extra space foreseen image2D(z = volcano.clab = 2) ## ======================================================================= ## colorkey added to existing plot ## ======================================================================= par(mfrow = c(1. length = 0. font. 2)) pmar <.1.5) colkey(side = 3. shade = 0.clab = "red". 1). xlab = "". clab = "z".2. colkey = list(side = 1. col = "grey".

ticks = "white".clab = 2. width = 0.axis = "white". col.axis = 0. cex.5. width = 0. shift = -0. cex. side = 3.clab = "white". m". col. col. ] # add as image with own color key.clab = "white".8. cex. labels = c("a".3.axis = 0. shift = 0.5.8)) ## ======================================================================= ## Several color keys in composite plot ## ======================================================================= persp3D(z = volcano. col. 200).2.4. lphi = 90.ticks = "white"."m"). width = 0. length = 0.2. shift = -0.volcano[-1.8. length = 0. colkey = list(dist = -0.5. 1)) image2D(volcano.5. font = 2) colkey(clim = range(volcano).clab = 0.85). cex.1. col.clab = 0. 1)) par(mar = par("mar") + c(0.axis = 0. side = 3.15.3. col. lighting = TRUE. length = 0. width = 0. add = TRUE. colvar = Vx/10. las = 3) ## ======================================================================= ## colorkey in other plots ## ======================================================================= par(mfrow = c(1.ticks = "white". plot = FALSE) # create gradient in x-direction Vx <.box = "red". colkey = FALSE) colkey(clim = range(volcano).Color key legend par(mfrow = c(1. col. clab = c("height".ticks = "white".ticks = "white".15.4. at bottom image3D(z = -60.8) colkey(clim = range(volcano). side = 4. col.clab = 2.5. length = 0. add = TRUE. at = c(100. side = 2.15. line. add = TRUE. dist = -0. cex. dist = -0. bty = "b". add = TRUE.2.axis = 0.volcano[-nrow(volcano). clab = "key 3".8. col.5. colkey = list(length = 0. clab = "key 2". width = 0. add = TRUE. 140. col. 49 .2. clab = "height. zlim = c(-60.5.clab = "white".axis = "white". phi = 20. -2. length = 0. colkey = list(length = 0. width = 0. shift = 0. clab = "key 4". col. width = 0.85).3. col. 0)) image2D(volcano. dist = -0. col.axis = 0.2.axis = 0.8) colkey(clim = range(volcano).clab = "white". ] .axis = "white". cex.box = "red".axis = "white".3.2. side = 1. col. shift = 0.3. dist = -0. clab = "key 1". col. cex. cex.15.axis = "white". col. 0. shift = -0. "c"). 180). cex.clab = "white". "b".5. col.

clim = c(1. use addlines = TRUE to separate colors ## ======================================================================= with(iris. "virginica") ))) # reset plotting parameters par(mfrow = pm) par(mar = pmar) Colors Colors. colvar = as.col creates transparent colors. 2. labels = c("setosa". "versicolor".5. plot = TRUE) ## ======================================================================= ## categorical colors.Width.5) . ticktype = "detailed". ylab = "Sepal Width".Length. ramp. colkey = list(at = c(1. 2. zlab = "Petal Length". alpha = 0. main = "iris". phi = 20.5. alpha. alpha = 1) gg. addlines = TRUE.50 Colors clab = c("gradient". shading.col generates the matlab-type colors.Length.col (n = 100.col creates color schemes by interpolation. alpha = 1) alpha.col (col = "grey". "green". n = 100. lighting. "black"). Description jet.col (col = c("grey".col (n = 100. alpha = 1) ramp. alpha = 1) gg2."m/m"). length = 0. jet2.col and gg2. alpha = 1) jet2.col is similar but lacks the deep blue colors gg. cex = 2. side = 1.66).col (n = 100.integer(Species). scatter3D(x = Sepal. y = Sepal. xlab = "Sepal Length".col generate gg-plot-like colors.33.col (n = 100. pch = 16. Usage jet. 3). width = 0. col = c("orange". "lightblue"). z = Petal.

specular = 1.. To make colors transparent.plot is a color-blind friendly palette from http://wiki. or made transparent. the argument shade should be given a value inbetween 0 and 1. Toggling on lighting or shading also requires the input of the angles of the light source.nl> References The gg-plot type of colors gg. To combine transparency with lighting or shading. col Colors to interpolate. the argument lighting should be either set to TRUE (in which case default settings will be used) or should be a list with specifications of one of the following: ambient.sr) * Is where Is = specular * abs(Light) ^ exponent. y-.6. . then col = (ambient + Id + sr * Is) * col + (1 .soetaert@nioz. Shading will be overruled if lighting is not FALSE. specular. The lighting algorithm is very simple. and alpha. whose defaults are: ltheta = -135.3. with a value inbetween 0 and 1.Colors 51 Arguments n Number of colors to generate. colors can also be adapted by shading and lighting. use argument alpha. as ltheta and lphi. diffuse. The defaults are: ambient = 0. See Also colorRamp and colorRampPalette for comparable (and more elaborate) R-functions. 1] for alpha transparency channel (0 means transparent and 1 means opaque). diffuse = 0. x-. pass argument alpha to the plotting functions directly. Id = diffuse * Light and Light = sum(N*I). z direction) and I is the light vector. This usually works well for shading. Details In addition to the color functions described here. sr = 0. To switch on lighting. Value A list with colors. If N is the normal vector on the facets (3-values. To switch on shading.stdout. i. no interpolation. change. diffuse and specular light. Author(s) Karline Soetaert <karline. but may not be optimal for lighting. it is flat shading. exponent. Transparency defined in the color palette is overruled when lighting or shading is switched on.e. alpha Value in the range [0. org/rcookbook/Graphs. lphi = 0. exponent = 20. alpha = 1 Lighting is defined as the sum of ambient.

52

Colors

Examples
# save plotting parameters
pm <- par("mfrow")
pmar <- par("mar")
## =======================================================================
## Transparency and various color schemes
## =======================================================================
par(mfrow = c(3, 3))
for (alph in c(0.25, 0.75))
image2D(volcano, alpha = alph,
main = paste("jet.col, alpha = ", alph))
image2D(volcano, main = "jet.col")
image2D(volcano, col = jet2.col(100), main = "jet2.col")
image2D(volcano, col = gg.col(100), main = "gg.col")
image2D(volcano, col = gg2.col(100), main = "gg2.col")
image2D(volcano, col = rainbow(100), main = "rainbow")
image2D(volcano, col = terrain.colors(100), main = "terrain.colors")
image2D(volcano, col = ramp.col(c("blue", "yellow", "green", "red")),
main = "ramp.col")
## =======================================================================
## Shading, lighting - one color
## =======================================================================
# create grid matrices
X
<- seq(0, pi, length.out = 50)
Y
<- seq(0, 2*pi, length.out = 50)
M
<- mesh(X, Y)
phi
<- M$x
theta <- M$y
# x, y and z grids
x <- sin(phi) * cos(theta)
y <- cos(phi)
z <- sin(phi) * sin(theta)
# these are the defaults
p <- list(ambient = 0.3, diffuse = 0.6, specular = 1.,
exponent = 20, sr = 0, alpha = 1)
par(mfrow = c(3, 3), mar = c(0, 0, 0, 0))
Col <- "red"
surf3D(x,
surf3D(x,
surf3D(x,
surf3D(x,
surf3D(x,
surf3D(x,
surf3D(x,

y,
y,
y,
y,
y,
y,
y,

z,
z,
z,
z,
z,
z,
z,

box
box
box
box
box
box
box

=
=
=
=
=
=
=

FALSE,
FALSE,
FALSE,
FALSE,
FALSE,
FALSE,
FALSE,

col
col
col
col
col
col
col

=
=
=
=
=
=
=

Col,
Col,
Col,
Col,
Col,
Col,
Col,

shade = 0.9)
lighting = TRUE)
lighting = list(ambient = 0))
lighting = list(diffuse = 0))
lighting = list(diffuse = 1))
lighting = list(specular = 0))
lighting = list(exponent = 5))

Colors

53

surf3D(x, y, z, box = FALSE, col = Col, lighting = list(exponent = 50))
surf3D(x, y, z, box = FALSE, col = Col, lighting = list(sr = 1))
## =======================================================================
## Shading, lighting with default colors
## =======================================================================
x <- seq(-pi, pi, len = 100)
y <- seq(-pi, pi, len = 100)
grid <- mesh(x, y)
z
cv

<- with(grid, cos(x) * sin(y))
<- with(grid, -cos(y) * sin(x))

# lphi = 180, ltheta = -130 - good for shade
# lphi = 90, ltheta = 0 - good for lighting
par(mfrow = c(2, 2))
persp3D(z = z, x = x, y = y, colvar = cv, zlim = c(-3,
persp3D(z = z, x = x, y = y, colvar = cv, zlim = c(-3,
lighting = TRUE, colkey = FALSE)
persp3D(z = z, x = x, y = y, colvar = cv, zlim = c(-3,
shade = 0.25, colkey = FALSE)
persp3D(z = z, x = x, y = y, colvar = cv, zlim = c(-3,
lighting = TRUE, lphi = 90, ltheta = 0, colkey =

3), colkey = FALSE)
3),
3),
3),
FALSE)

## =======================================================================
## transparency of a vector of colors
## =======================================================================
par(mfrow = c(1, 1))
x <- runif(19)
y <- runif(19)
z <- runif(19)
# split into 5 sections (polygons)
ii <- seq(4, 19, by = 4)
x[ii] <- y[ii] <- z[ii] <- NA
polygon3D(x, y, z, border = "black", lwd = 2,
col = alpha.col(c("red", "lightblue", "yellow", "green", "black"),
alpha = 0.4))
# the same, now passing alpha as an argument to polygon3D:
## Not run:
polygon3D(x, y, z, border = "black", lwd = 2,
col = c("red", "lightblue", "yellow", "green", "black"),
alpha = 0.4)
## End(Not run)
# reset plotting parameters
par(mfrow = pm)
par(mar = pmar)

54

Composite plots

Composite plots

Handling and plotting plotting lists.

Description
S3 method plot.plist and function plotdev plot the plotting list to the current device. Changes
can be made to the perspective view, to the lighting and shading, or to make colors transparent.
getplist and setplist retrieve and store information in the plotting list.
selectplist selects parts from the plotting list, based on a user-defined function.
Usage
getplist()
setplist(plist)
plotdev(...)
## S3 method for class 'plist'
plot(x, ...)
selectplist(plist, SS)
Arguments
x, plist

The plotting list as generated (invisibly) by any of the 3D plotting functions.

SS

Function which tests points for inclusion in the plotting list. It should take as
argument three vectors (x, y, z) and return a vector of equal length that is either
TRUE or FALSE, denoting whether the point should be selected or not.

...

Additional arguments to change the view or coloration. Supported arguments to
change the view are : theta, phi, xlim, ylim, zlim, d, r, scale, expand.
See perspbox, persp.
Supported arguments to change the lighting, or coloration are : ltheta, lphi, shade, lighting.
See jet.col.

Details
All 3-D functions from package plot3D produce or update a plotting list that is local to the package.
One can access this plotting list via getplist and setplist. The list is used to plot when, in a 3-D
function, the argument plot is TRUE or via function plotdev.
The plotting list can contain the following items:
• mat, the viewing transformation matrix, a 4 x 4 matrix suitable for projecting 3D coordinates
(x, y, z) into the 2D plane using homogeneous 4D coordinates (x,y,z,v).
It can be used to superimpose additional graphical elements on the 3D plot, by any function
that is defined on persp.
It can also be used to add lines, arrows or points, using the function trans3D.
• plt, with original plt parameters and the plt parameters used for the main frame.
• persp, with settings for the perspective box.

Composite plots

55

• xlim, ylim, zlim, with ranges.
• scalefac, the scaling factors in x, y and z direction, used e.g. for shading.
• dot other plotting parameters passed to persp.
• colkey, numkey, with settings for the color key(s).
• poly, segm, pt, CIpt, labels, arr the information for drawing polygons, segments,
points, points with confidence intervals, labels and arrows, that are part of the plot.
For the item poly the elements are:
• x, y, z : A matrix with typically 4 or 5 rows, the first rows defining the x-, y- or z- values of
each polygon, the last row contains NA (and which therefore terminates a polygon).
• col: a vector with the colors for the facets of each polygon.
• lwd, lty, border: a vector with the line widths, line type and colors for the border of each
polygon. (note in R-function polygon, passing a vector of line widths is not implemented;
therefore, only the first value of lwd will be used for all polygons).
When plot.plist is called, the projection depth is calculated and used to sort the facets and
function polygon used to draw them.
Value
Returns the updated plotting list.
Note
Once a 3D plot has been generated, a new device can be opened and plotdev used to plot also on
this device.
plotdev and plot(getplist()) are the same.
In an extension package, plot3Drgl, a similar function, plotrgl, plots the graphs to the device
opened with rgl. This allows interactive zooming, rotating, etc...
Author(s)
Karline Soetaert <karline.soetaert@nioz.nl>
Examples
# save plotting parameters
pm
<- par("mfrow")
pmar <- par("mar")
## ========================================================================
## The volcano
## ========================================================================
par(mfrow = c(2, 2), mar = c(2, 2, 2, 2))
# The volcano at lower resolution
x <- seq(1, nrow(volcano), by = 2)

out = 30)) u <. 0. z = 2*z. pi. lighting = TRUE.mesh(seq(0.6). phi = 60) ## ======================================================================== ## Two spheres ## ======================================================================== par(mfrow = c(1. colvar = NULL. 1).pdf") plotdev() dev. col = "blue".y] persp3D(z = V) # rotate plotdev(theta = 0) # light and transparence plotdev(lighting = TRUE.sin(u)*sin(v) z <. length. 0.cos(u)*sin(v) y <.M$y x <.off() ## End(Not run) ## ======================================================================== ## Two spheres and two planes ## ======================================================================== par(mar = c(2. ylim = c(0. v <. length. by = 2) V <. seq(0. 0.6). y = 2*y. ncol(volcano). lwd = 5) surf3D(x. facets = NA. y. 2)) . #plot = FALSE. 2. mar = c(0. col = "red". lphi = 90. alpha = 0. add = TRUE) names(getplist()) # plot with different view: plotdev(phi = 0) ## Not run: # will plot same 3-D graph to pdf pdf(file = "save.volcano[x.cos(v) surf3D(x = 2*x.2.M$x .6) # zoom plotdev(xlim = c(0. 0. z.seq(1. lighting = TRUE.56 Composite plots y <. 2*pi. 0)) # create a sphere M <. colvar = NULL. 2.out = 30).2.

5). theta = 45. length. plot = TRUE) ## Not run: # rotate for (angle in seq(0.out = Ny) image3D (x = x.here x and y have to be matrices! x <. colvar = z. 360. z. add = TRUE. plot = FALSE) # add a second sphere. length. z = 0.5. 1.M$x . small plane at y = 0 .sin(u)*sin(v) z <. # no facets drawn for this sphere surf3D (x.100 x <.. length. 2). y = y. by = 10)) plotdev(theta = angle) ## End(Not run) ## ======================================================================== ## Zooming. add = TRUE. phi = 20.seq(-1. ## ======================================================================== par(mfrow = c(2.seq(-1.out = 100). facets = TRUE. border = "blue".100 Ny <. col = "blue". by = 2) seq(1. colvar = NULL. 2*pi. z.M$y x <. ylim = c(-1. colvar = NULL. col = NA.cos(v) surf3D(x. shifted 1 unit to the right on y-axis.. facets = TRUE..seq(-1. seq(0. rescaling.5.5.. add = TRUE. 1.out = 50) image3D (x = x. v <.seq(-1. ncol(volcano). bty = "b". lighting. length.out = Nx) y <.. 1. zlim = c(-1. 1. nrow(volcano).out = 50) z <. 1. plot = FALSE) # define a plane at z = 0 Nx <.Composite plots # equation of a sphere M <. plot = FALSE) # another. y.mesh(seq(0. colvar = z. y+1. facets = FALSE. y = 0. z = z. length.out = 100)) u <.y] 57 - . xlim = c(-1. pi.5. by = 2) volcano[x.cos(u)*sin(v) y <.5).. 2)) # The x <y <V <- volcano seq(1. length. 2..

facets = NA.3) # zoom and rotate plotdev(xlim = c(10. phi = 50) ## ======================================================================== ## Using setplist ## ======================================================================== polygon3D(runif(3). 1). plot = FALSE.5. expand = 0. transparant: only border image3D(x. col = "yellow"."red" # update internal plotting list setplist(plist) # plot updated list plotdev() ## ======================================================================== ## Using selectplist ## ======================================================================== polygon3D(runif(10). box = FALSE. xlim = c(0. runif(10). plot = FALSE. runif(10). theta = 10. plot = FALSE.2. runif(10). and shading plotdev(d = 2. runif(10). add = TRUE. colkey = FALSE) # add a contour (image) at z = 170.2. runif(10). zlim = c(0. alpha = 0. runif(3). 30). clim = range(V). jetcolored. add = TRUE) polygon3D(runif(10)*0.2. 1)) polygon3D(runif(10)*0. z = 170. runif(3)) # retrieve plotting list plist <. shade = 0. 30). phi = 20.getplist() names(plist) plist$poly # change copy of plotting list plist$poly$col <. z = 170. add = TRUE.5+0. ticktype = "detailed". scale = FALSE. ylim = c(0. r = 10. colvar = V. y. y. alpha = 0.3. y.5. col = "red". add = TRUE) . ylim = c(20.58 Composite plots # plot the volcano persp3D (x. z = V. runif(10). colkey = FALSE) # plot it plot(getplist()) # same as plotdev() # plot but with different expansion plotdev(expand = 1) # other perspective. jetcolored. clim = range(V). contour3D(x. colvar = V. plot = FALSE) # add a plane (image) at z = 170. clim = range(V). plot = FALSE. colvar = V. col = "green".1). plot = FALSE. alpha = 0.

to the (x-z) plane (y one number) or to the (z-y) plane (z one number). clab = NULL. colkey = NULL.out = length(x)) sel[x < 0. clim = NULL.. y1 = runif(10).. . facets = TRUE. or one value containing the values where the image is to be plotted. as this will determine where the image is plotted. z) { sel <. theta = 40. xlim = c(0.col(100). col = jet. 1)) # restore plotting parameters par(mfrow = pm) par(mar = pmar) images in 3D frame Images in 3-D plots. y0 = runif(10). plot(x = selectplist(plist..getplist() # selection function SS <. z = NULL.first = NULL.5] <. the first vector should be of length equal to nrow(colvar) and the second should be of length equal to ncol(colvar). z Matrix (2-D). plot = TRUE) Arguments x. y = NULL. panel. colvar = NULL.rep(TRUE. z1 = runif(10). add = TRUE.FALSE return(sel) } # The whole polygon will be removed or kept. colvar The variable used for coloring. Usage image3D (x = NULL. 1). . ylim = c(0. bty = "b". SS). parallel to the (y-z) plane (x one number). y. phi = 40. length. 1). vector. runif(10). col = "blue". lwd = 3) # retrieve plotting list plist <. zlim = c(0. runif(10). x1 = runif(10).function (x. At least one of them should be one number. y. NAcol = "white".images in 3D frame 59 points3D(runif(10). Description image3D adds an image in a 3-D plot. plot = FALSE) segments3D(x0 = runif(10). add = FALSE. inttype = 1. resfac = 1. z0 = runif(10). add = TRUE. colvar = 1:10. border = NA. If two are vectors.

one value or a vector of two numbers. z will be interpolated to two intermediary points. 3 or extending the x. see persp. and the axis parameters at. NAcol Color to be used for NA values of colvar. clab can be made a vector. or a list with parameters for the color key (legend). dist. It is usually faster to draw with facets = FALSE. length. If NA then the facets will be transparent. The default. If FALSE. Values 1. this will tend to make the NA region smaller. with the first values empty strings. Values of colvar that extend the range will be put to NA. font. inttype The interpolation type to create the polygons. then col denotes the color of the surface facets. then the surface facets are colored “white” and the border (if NA) will be colored as specified by col. theta gives the azimuthal direction and phi the colatitude. line. The label will be written at the same level as the main title. to lower it. The function should have as argument the transformation matrix. phi The angles defining the viewing direction. panel. either taking the mean of the colvar variable (inttype = 1. lwd. i. Setting colkey = list(plot = FALSE) will create room for the color key without drawing it. the default only drawing background panels. labels. If TRUE. lwd. it should be defined as function(pmat). co The defaults for the parameters are side = 4. This uses simple linear interpolation. If resfac is one number then the resolution will be increased similarly in x and y-direction. resfac Resolution factor. dist = 0. A value > 1 will increase the resolution. NULL (default). shift. addlines. tick. images or contours drawn) but before any plotting takes place. For instance. width. 3 differ in how they treat NAs in the colvar variable.first A function to be evaluated after the plot axes are set up (and if applicable. Only effective if the persp argument (box) equals TRUE (this is the default). plot. This can be useful for drawing background grids or scatterplot smooths.and y-values. NAs are included when inttype = 1. e. pos. add Logical. bty The type of the box. clim Only if colvar is specified. NA. if resfac equals 3 then for each adjacent pair of x. see details and an example in persp3D.60 images in 3D frame col Color palette to be used for the colvar variable. lty.clab. theta. If FALSE a new plot is started. length = 1.e. the range of the color variable. col. border The color of the lines drawn around the surface facets. The default is to draw the color key on side = 4. width = 1. List parameters should be one of side. See example of persp3D and last example of voxel3D. y. NAs are removed before taking averages. This will tend to make the NA region larger. plot = TRUE. for the x and y.values respectively. facets If TRUE. no color key legend will be added. then the image will be added to the current plot.g. See perspbox. used for the color key. colkey A logical.ticks. If colkey = NULL then a color key will be added only if col is a vector. if colkey = FALSE. z values (inttype = 2). . For inttype = 3. clab Only if colkey = TRUE. in the right margin. default is “white”. See colkey. the label to be written on top of the color key. will disable the drawing of borders. outer.

y. 1. z plane ## ======================================================================= par(mfrow = c(2. colkey = list(plot = FALSE)) image3D(x = seq(0. a plot is created. col = "blue". . 1. alpha can be given a value inbetween 0 and 1 to make colors transparent. 0.1).grid. col = "red". In addition.. The arguments after . lwd. image2D for plot3Ds 2-D image function.1). 0. sub. The x.5. col. 2)) # images in x. ylab..2) # alpha makes it transparent image3D(x = seq(0. y = seq(0. additional arguments passed to the plotting methods. z = seq(0. col. add = TRUE. ylim. shade and lighting arguments will have no effect. 1. See trans3D. y. z = seq(0. 1. use plotdev. z plane # We use colkey = list(plot = FALSE) to create room for a color key image3D(y = seq(0. main. 0.5. alpha = 0. xlab. Author(s) Karline Soetaert <karline. x = 0.1). Also the arguments lty.1). 0. the perspbox arguments col.grid can also be given a value. .images in 3D frame 61 plot Logical. including those that fall out of these ranges. The following persp arguments can be specified: xlim. 0.1). 1.panel. y. lwd can be specified (when border is not NA).5. To select objects only within the axis limits.1).panel. must be matched exactly. zlim.par("mfrow") ## ======================================================================= ## images in x. and z values are expanded as a matrix.axis. . xlim = c(0. Value Returns the viewing transformation matrix. lwd. If TRUE (default). Details image3D calls the surf3D function. zlim only affect the axes. The arguments xlim. Examples # save plotting parameters pm <. 1. ylim. .1). zlab. 0. y = 0. z = 0.nl> See Also surf3D for the function on which image3D is based.soetaert@nioz. otherwise the viewing transformation matrix is returned (as invisible). All objects will be plotted.

clab = c("height". Usage mesh (x. add = TRUE) # image3D( z = 1. col = "orange". xlim = c(0.y. 1). "m")) image3D( x = 0.out = ncol(volcano)). 1. 2)) image3D(y = 2. xlim = c(0. The dimensions of these list elements are the same and equal to c(length(x). zlim = c(0. colvar = volcano. length. z = seq(1. 150). 2. 2. length.out = nrow(volcano)). labels = c("z". 1. length(y). 1). y = seq(0. ylim = c(0. They can be of arbitrary length. x = seq(0. ylim = c(0. shade = 0. y = seq(0. colvar = volcano. "red". length. length. length. "blue"). z Vectors with x. x = seq(0. colvar = volcano.5). length.62 Mesh generation # # add = TRUE.out = nrow(volcano)). 1)) image3D( y = 0. "x"). 1. colvar = NULL. zlim = c(0.out = ncol(volcano))) image3D(x = 2.5. y. 1. Description mesh creates a rectangular full 2-D or 3-D grid. y and z-values. "y". col = "green") colkey(col = c("green". zlim = c(0. add = TRUE.2. y. . z = seq(1. 2). add = TRUE) image3D(z = 100. 2). Value Function mesh returns a list with the expanded x. add = TRUE. clim = c(0.out = nrow(volcano)). at = 1:3. colvar = volcano. colvar = volcano.5. 3.5.out = ncol(volcano))) # reset plotting parameters par(mfrow = pm) Mesh generation Rectangular grids. length(z)). z = NULL) Arguments x.and z arrays (in case z is not NULL) or matrices (in case z = NULL).

soetaert@nioz.with (M. . colkey = FALSE) Perspective box Creates an empty perspective box. 0. 0. z)) # calculate with 3-D mesh V <. x/2 * sin(y)) # same as: V2 <. FUN = function(x. surf3D for other examples that use mesh. and makes space for a colorkey (if any). x/2 * sin(y) *sqrt(z+2)) # plot result scatter3D(M$x. V.mesh(x. cex = 3. y)) # calculate with this mesh V <. 1) y <. Examples ## ======================================================================== ## 2-D mesh ## ======================================================================== x <. y. slice3D. pch = "+". arrows3D.y <. M$y.nl> See Also persp3D.c(-1 .with (M.mesh(x.Perspective box 63 Author(s) Karline Soetaert <karline. 1) # 3-D mesh (M <. ready for adding objects Description perspbox draws a box and labels.z <.c(-1 . y) x/2*sin(y)) ## ======================================================================== ## 3-D mesh ## ======================================================================== x <.outer(x. y. M$z.1 : 4 # 2-D mesh (M <.

"f".. width = 1. bty = c("b". plot.. lwd. z Matrix or vector with z-values. y Vectors with x and y values. "bl" has a black background. List parameters should be one of side. bty The type of the box. if colkey = FALSE.e. as they will not be drawn.axis. y = seq(0. addlines. will be ignored. col. col. "n" means that no box will be drawn.grid = 1. . Only used if bty = "u". lwd. in the right margin. lwd. col. length = 1. 1. otherwise the viewing transformation matrix is returned (as invisible).out = ncol(z)). col.clab. only effective if the persp argument box equals TRUE (the default).. col. lwd. additional arguments passed to persp. dist. lwd. of the axis panel or of the grid lines. i.grid manually. co The defaults for the parameters are side = 4.and yvalues. "bl".panel.panel.panel.panel = 1. outer. when "b2" has back panels and grid lines.out = nrow(z)). col. it is sufficient to pass a diagonal matrix with the range of the z-values. "n"). "g". It is sufficient to pass the ranges of the x. tick. a plot is created. z. shift. Unless bty is equal to "u" then the arguments col.axis. phi The angles defining the viewing direction. or a list with parameters for the color key (legend). lwd.grid. "g" has grey background with white gridlines. "b2". The default is to draw the color key on side = 4.axis.ticks.grid The width of the panel border or of the grid lines. lwd. width. If TRUE (default). see persp. theta. lty. If z is a matrix. Here only used for assessing if a color key should be drawn. plot = TRUE. col. "f" is the full box. phi = 40.axis = "black".. col.panel. lwd. "bl2".grid. NULL (default). pos. This is the same as setting box = FALSE. Setting colkey = list(plot = FALSE) will create room for the color key without drawing it. plot = TRUE) . Only used if bty = "u". lwd. dist = 0. If colkey = NULL then a color key will be added only if col is a vector. "u" means that the user will specify the arguments col. it is required that length(x) = nrow(z) and length(y) = ncol(z). length. If z is a matrix. colkey = NULL.. "bl2" has a black background with grey lines. 1.panel. "u". length. as they will not be drawn.panel. col. no color key legend will be added. Arguments x. labels. theta gives the azimuthal direction and phi the colatitude. "b" has only the back panels visible.grid = NULL. col Colors to be used for coloring the colvar variable. line. col = NULL. col. colkey A logical.64 Perspective box Usage perspbox (x = seq(0. font. . theta = 40. and the axis parameters at. plot Logical. the default as from persp. col. length.grid The color of the axis line. See colkey.panel = NULL.

1. “g”: only backward panels shown. All objects will be plotted. zlim. ylab. 1. including those that fall out of these ranges.grid = 2 and col. col. Author(s) Karline Soetaert <karline. Details The arguments xlim. scatter2D. The arguments after . The predefined box types bty are defined as follows: “f”: all panels are shown and transparent. lwd.grid = "white". col. zlab. ylim.panel = "black". also the persp default. must be matched exactly. Arguments scale and expand affect the size of the axes. d = 2. surf3D for examples where box types different than the default are used.grid = 2 and col. “bl”: only backward panels shown.Perspective box 65 The following persp arguments can be specified: xlim. main = "bty = 'b'") # box as in 'persp' perspbox(z = volcano. “b2”: as “b” with col. ticktype = "detailed". bty = "f". use plotdev. ticktype = "detailed". col. lwd. sub. Examples # save plotting parameters pm <. Hypsometry for an example where colored axis-panels are added to a figure started with perspbox. Value Function perspbox returns the viewing transformation matrix. 1)) # box type with only backward panels perspbox(z = volcano. . zlim only affect the axes. col. ylim. . xlab. To select objects only within the axis limits.grid = "white".95).nl> See Also persp3D. “b”: only backward panels shown. “n”: no box is drawn.par("mfrow") pmar <.axis = "grey".grid = "grey". 2). mar = c(1.soetaert@nioz. See trans3D. . bty = "b".par("mar") ## ======================================================================== ## The 4 predefined box types ## ======================================================================== par(mfrow = c(2.panel = grey(0. main.axis = "grey".

plot = TRUE) . simple axes perspbox(z = volcano. y..grid = "grey".. col = NULL... main = "bty = 'b2'") # ggplot-type. d = 2. z.first = NULL. 1)) perspbox(z = diag(2). main = "bty = 'f'") # back panels with gridlines. ticktype = "detailed". main = "bty = 'g'") ## ======================================================================== ## A user-defined box ## ======================================================================== par(mfrow = c(1. type = "l") points2D is shorthand for scatter2D(. points3D is shorthand for scatter3D(. panel. main = "user-defined") # restore plotting parameters par(mfrow = pm) par(mar = pmar) Scatter plots Colored scatter plots and text in 2-D and 3-D Description scatter2D and scatter3D plot a (2... CI = NULL. type = "p") lines3D is shorthand for scatter3D(. bty = "u". text3D plot a 3-D dataset with a color variable as text labels. scale = FALSE.. detailed axes perspbox(z = volcano. col. type = "l") The 2D functions scatter2D and text2D are included for their side effect of having a color key. ticktype = "detailed".panel = "gold".. bty = "b2". type = "p") lines2D is shorthand for scatter2D(. colvar = z. bty = "g". surf = NULL. d = 2.66 Scatter plots d = 2.4. NAcol = "white". clab = NULL. expand = 0. bty = "b". add = FALSE. clim = NULL.. colkey = NULL. Usage scatter3D (x. col.. col. phi = 40..or 3 dimensional) dataset with a color variable as points or lines.axis = "white". . theta = 40.....

add = FALSE. . NAcol = "white". addlines. labels. if colkey = FALSE. no color key legend will be added. labels. plot = TRUE) text2D (x. pos. font. and the axis parameters at. y. colkey = NULL. plot = TRUE. and the color. z).clab. NAcol = "white". z. clim = NULL.. List parameters should be one of side. .. See colkey. lty = par("lty"). outer. y. col = NU to set the length of the arrow head. plot = TRUE) Arguments x. panel. or a list with parameters for the color key (legend). clab = NULL.Scatter plots 67 text3D (x. . clab = NULL.. width. lwd. The default is to draw the color key on side = 4. CI = NULL. lwd. then col will be "black". Setting colkey = list(plot = FALSE) will create room for the color key without drawing it. . it need not be present. theta gives the azimuthal direction and phi the colatitude. dist.. col = NULL. colvar The variable used for coloring. i. colkey = NULL. If col is NULL and colvar is specified. z. length = 1. colkey = NULL. If a list it should contain at least the item x..01. See examples.. col = NULL. add = FALSE. colvar = NULL. NAcol Colors to be used for colvar values that are NA. z Vectors with x. then a red-yellow-blue colorscheme (jet. If col is NULL and colvar is not specified. plot. phi the angles defining the viewing direction. y.first = NULL. it should be a vector of equal length as (x. y and z-values of the points to be plotted.. defining the left/right intervals.. colvar = NULL.col) will be used. NULL (default).. co The defaults for the parameters are side = 4.ticks. theta = 40. CI A list with parameters and values for the confidence intervals or NULL.. col Color palette to be used for coloring the colvar variable. colkey A logical.. NAcol = "white". in the right margin. see persp. y. Other parameters should be one of (with defaults): alen = 0. clim = NULL. tick. the line type and width. . If colkey = NULL then a color key will be added only if col is a vector. For scatter3D.) scatter2D (x. z. If col is NULL. then the colors as specified by colvar are used. but if specified. clim = NULL. add = FALSE.. lty. They should be of equal length.. y. lwd = par("lwd"). line. y. width = 1. col = NULL.e. length. theta. shift. y. plot = TRUE) points3D (x. . phi = 40. colvar = NULL. dist = 0. labels. y or z (latter for scatter3D). bty = "b". col. clab = NULL.) lines3D (x. These should be 2-columned matrices. and the same length as colvar (if present).

. For all functions. defining the surface. the range of the color variable. sub. and optional: colvar. Note For scatter2D and scatter3D the plottypes that are supported are: type = "p". The arguments after .grid. labels The text to be written.g. To lower it. "b2". must be matched exactly. clab Only if colkey is not NULL or FALSE. then pch. type = "h". ylab. col. xlab. then the points will be added to the current plot. Value Function scatter3D returns the viewing transformation matrix. main. The following persp arguments can be specified: xlim. If TRUE. type = "l". this will produce droplines from points to the fitted surface. . Only effective if the persp argument (box) equals TRUE (this is the default). type = "o". ylim. zlab. bg can also be specified. If FALSE a new plot is started. the perspbox arguments col. For type = "b".. . . Note: the bty = "g". y. used for the color key. See example of persp3D and last example of voxel3D. the label to be written on top of the color key. The argument fit should give the fitted z-values.68 Scatter plots panel. ylim.grid can also be given a value. To select objects only within the axis limits. z. See trans3D. for instance produced by predict. bty The type of the box. type can be specified for all except text3D. zlim only affect the axes for 3D plots. The list should include at least x. type = "o" is used instead. zlim. in the same order as the zvalues of the scatter points. The function should have as argument the transformation matrix. clim Only if colvar is specified.panel. y. a list specifying a (fitted) surface to be added on the scatterplot. lwd can be specified. use plotdev. fac Note that the default is that colvar is not specified which will set colvar = z.first A function to be evaluated after the plot axes are set up but before any plotting takes place. col. If TRUE (default). See perspbox.. surf If not NULL. NAcol. "bl" can also be specified for scatter2D (if add = FALSE).panel. When present. lwd. the arguments lty. including those that fall out of these ranges. col.axis. In case type = "p" or "b". it should be defined as function(pmat). The arguments xlim. border. a plot is created. Values of colvar that extend the range will be put to NA. additional arguments passed to the plotting methods. The label will be written at the same level as the main title. add Logical. z. cex. with the first values empty strings. In addition. e. otherwise (for 3D plots) the viewing transformation matrix is returned (as invisible). plot Logical. This can be useful for drawing background grids or scatterplot smooths. clab can be made a vector. alpha can be given a value inbetween 0 and 1 to make colors transparent. shade and lighting arguments will have no effect. All objects will be plotted. the default draws only the back panels. A vector of length equal to length of x. lwd.

z.sin(z)*z # greyish background for the boxtype (bty = "g") scatter3D(x. colkey = FALSE) ## ======================================================================= ## Different types ## ======================================================================= par (mfrow = c(2. 0.Scatter plots Author(s) Karline Soetaert <karline. z = 0. length. length.cos(u)*sin(v) y <. pi. 2*pi. pch = 18.M$y x <. pch = ". trans3D. plotdev for zooming.par("mfrow") ## ======================================================================= ## A sphere ## ======================================================================= par(mfrow = c(1. 2)) z <. v <. cex = 2.mesh(seq(0.1). for other examples of scatter2D or scatter3D. 10. add = TRUE. rescaling. slice3D. bty = "g". pch = 20.out = 100)) u <. y = 0. y. Examples # save plotting parameters pm <. cex = 3. colkey = FALSE. y.sin(u)*sin(v) z <.M$x . z. col = "black") # add text text3D(x = cos(1:10). seq(0. cex = 2. package scatterplot3D for an implementation of scatterplots that is not based on persp.seq(0.nl> See Also persp for the function on which this implementation is based.2) x <. ticktype = "detailed") # add another point scatter3D(x = 0.cos(z) y <. y = (sin(1:10)*(1:10) . mesh.". col = "red".soetaert@nioz.cos(v) # full panels of box are drawn (bty = "f") scatter3D(x. 69 . bty = "f". rotating a plot. 1)) M <. phi = 0.out = 100).

05. y. col = c("black". phi = 0. 1). xlim = c(0. pch = 16) ## ======================================================================= ## With a surface ## ======================================================================= par(mfrow = c(1.05. type = "l". ticktype = "detailed".5)) # vertical lines scatter3D(x. phi = 0. ## ======================================================================= ## With confidence interval ## ======================================================================= x <. z. cex = c(0.runif(20) y <.70 Scatter plots z = 1:10. col = "red". 2*length(x))). data = rep(0. data = rep(0. bty = "g". add = TRUE. add = TRUE. z. bty = "g". 1:ncol(volcano)) . phi = 0. zlim = c(0.runif(20) par(mfrow = c(1.list(x = matrix(nrow = length(x). 1)) # surface = volcano M <. "red")) # line plot scatter3D(x.05. type = "b".runif(20) z <. ticktype = "detailed". pch = 20. ylim = c(0.list(z = matrix(nrow = length(x). 1. 2*length(x)))) # greyish background for the boxtype (bty = "g") scatter3D(x. ticktype = "detailed". bty = "g". 1)) CI <. z = matrix(nrow = length(x). CI = CI. phi = 0. 1. 2*length(x)))) scatter3D(x. y. colkey = FALSE. 1)) # add x <y <z <- new set of points runif(20) runif(20) runif(20) CI2 <.5.col(100). ticktype = "detailed") type = "h". y. z. data = rep(0. col = gg. lwd = 4) # points and lines scatter3D(x. pch = 18.mesh(1:nrow(volcano). y. 1). z. bty = "g". CI = CI2. z. cex = 2. y. labels = LETTERS[1:10].

out = 30) disp. ticktype = "detailed". borders are black scatter3D(xs. facets = NA) ) ## ======================================================================= ## droplines till the fitted surface ## ======================================================================= with (mtcars.61).out = 30) xy <. 87).sin(xs) + ys + rnorm(N)*0. border = "black".seq(1. zs.3 CI <. ys. CI = CI.mesh(seq(0. 2*pi). 2*pi.list(z = matrix(nrow = length(xs). NAcol = "grey". data = rep(0. { # linear regression fit <. ylim = c(0. 2*length(xs))).Scatter plots # 100 points above volcano N <.30 xs <. sin(x) + y) # points 'sampled' N <.runif(N) * 87 ys <.5. z = volcano. pch = 16.grid(wt = wt. (1:30)/100) z <. bty = "f". ylim = c(1.expand.5). theta = 20. zlim = c(-1. disp = disp.3 zs <. xlim = c(0.seq(71. phi = 30.pred. xlim = c(1. zs.100 xs <. 1. 1)) M <. surf = list(x = M$x.runif(N) * 0. length = 30).3). pch = 16.pred <.runif(N)*50 + 154 # scatter + surface scatter3D(xs.5.runif(N) * 61 zs <. shade = 0.pred <. ys.lm(mpg ~ wt + disp) # predict values on regular xy grid wt. y = M$y. 5.pred) 71 . 215).with (M. lwd = 3) # facets = NA makes a transparent surface. length. surf = list(x = M$x.3. y = M$y. 0.runif(N) * 2*pi ys <.1)) ## ======================================================================= ## A surface and CI ## ======================================================================= par(mfrow = c(1. z = z.5. cex = 2. ticktype = "detailed". 472. length. zlim = c(94.

panel. km". theta = 10.min(quakes$long) XY <. nrow(quakes)). surf = list(x = wt.function(pmat) { zmin <. xlab = "wt". main = "Earthquakes off Fiji". fit = fitpoints). scatter3D(x = long. nrow(quakes)).clab = 0. pch = ". clab = c("Richter". pch = 16.5. add = TRUE.predict(fit) scatter3D(z = mpg. type = "h". x = wt. colvar = quakes$mag.5.pred. z = -depth.pred. data = predict(fit. z = -quakes$depth. 1)) # first way. colkey = list(length = 0. main = "Earthquakes off Fiji". y = quakes$lat. colvar = quakes$mag. pch = 18.5.75)) ) # second way: add dots on bottom and left panel # before the scatters are drawn. zlab = "depth. newdata = data. zlab = "depth. clab = c("Richter". colkey = FALSE) with(quakes."Magnitude"). xlab = "longitude". ticktype = "detailed". y = lat.frame(xy). d = 2. ylab = "latitude". pch = ".pred <. use vertical spikes (type = "h") with(quakes.". facets = NA. theta = 10. cex = 2.". cex = 2. ylab = "disp".first = panelfirst. XY$y. pmat = pmat) scatter2D(XY$x. scatter3D(x = long. km". xlab = "longitude". pmat = pmat) scatter2D(XY$x. ticktype = "detailed". colkey = FALSE) } xmin <.72 Scatter plots mpg. main = "mtcars") }) ## ======================================================================= ## Two ways to make a scatter 3D of quakes data set ## ======================================================================= par(mfrow = c(1. width = 0. quakes$lat. z = -depth. ylab = "latitude". d = 2. z = mpg. cex = 1. add = TRUE.5."Magnitude"). theta = 20.matrix (nrow = 30. interval = "prediction")) # fitted points for droplines to surface fitpoints <.trans3D(x = rep(xmin. colvar = mag. . colvar = mag. XY$y. zlab = "mpg".pred. pch = 16. ncol = 30. y = disp. cex = 1. cex = 2. y = disp. cex. y = lat. z = rep(zmin. ticktype = "detailed".trans3D(quakes$long. # add small dots on basal plane and on the depth plane panelfirst <. phi = 20.min(-quakes$depth) XY <.

5). pch = ". space = 0. cex = 0."ylim". ticktype = "detailed". 150). adj = 0. col = "#0072B2". d = 2. theta = -60. colvar = UrbanPop. main = "VADeaths". scatter3D(Murder.1. ticktype = "detailed".".5. colvar = UrbanPop.5. width = 0. Assault.axis = 1e-9) text3D(x = 1:5. theta = 60. add = TRUE. col = gg. z = rep(3. y = rep(0. adj = 0) text3D(x = rep(1. bty = "g". zlim = c(7. y = 1:4. 4). add = TRUE. 2)) 73 . d = 2. labels = rownames(VADeaths). z = VADeaths. bty = "g". ylab = "Assault". font = 2)) with(USArrests. phi = 20. border = "black". labels = rownames(USArrests). Rape . Assault. type = "h". shade = 0.5. cex. 1)) hist3D (x = 1:5."zlim")] # choose suitable ranges plotdev(xlim = c(0. z = rep(0. 5).8. add = TRUE)) ## ======================================================================= ## zoom near origin ## ======================================================================= # display axis ranges getplist()[c("xlim".and y axis ## ======================================================================= par(mfrow = c(1. xlab = "Murder". bty can also be set = to one of the perspbox alernatives ## ======================================================================= par(mfrow = c(2.clab = 0.75)) ) ## ======================================================================= ## text3D and scatter3D ## ======================================================================= with(USArrests. 10). y = 1:4. phi = 20. cex. adj = 1) ## ======================================================================= ## Scatter2D. Rape. clab = c("Urban". main = "USA arrests".15. 4).col(100).col(100). ylab = "". ylim = c(40. zlab = "Rape"."Pop"). text3D(Murder. labels = colnames(VADeaths). 25)) ## ======================================================================= ## text3D to label x.Scatter plots colkey = list(length = 0. col = gg. xlab = "".5. zlab = "".6.

seq(-2. colvar = cos(x). lwd = 4.0.5) # other box types: scatter2D(x.sqrt(x^2 + y^2) CI <. type = "b") CI$y <. colvar = cos(x). pch = 16.05.2) grid <. CI = CI) scatter2D(x. 2)) x <. pch = 16. y. ylab = "sin".25. colvar = cv. CI = CI) ## ======================================================================= ## Scatter on an image ## ======================================================================= par(mfrow = c(1.02 # increase arrow head scatter2D(x. x = x.5) ## ======================================================================= ## mesh examples and scatter2D ## ======================================================================= par(mfrow = c(1. alpha = 0. data = c(rep(0.4.out = 30) scatter2D(x.sort(rnorm(10)) y <. y = y) points(grid) scatter2D(grid$x. bty = "g") scatter2D(x. 1. y) z <. lwd = 4. y.seq(-1. y. colvar = cv. 2*length(x)))) scatter2D(x."black" scatter2D(x. 1)) # image of oxygen saturation . colvar = cos(x). lwd = 2. type = "l". bty = "b2") # transparent colors and spikes scatter2D(x. 2.8. colvar = z. cex = 2) ## ======================================================================= ## scatter plot with confidence intervals ## ======================================================================= par(mfrow = c(2.8. ] <. colvar = cos(x).10).matrix (nrow = length(x). cex = 2.matrix (nrow = length(x). type = "b". 2*pi. grid$y.1) y <. cex = 2. sin(x). cos(x) * sin(y)) image2D(z. by = 0. length. cex = 1. 2)) x <. pch = 20.mesh(x.NA # Some points have no CI CI$alen <. colvar = cv. ] <.runif(10) cv <. type = "h". CI = CI) CI$y[c(2. cex = 2. pch = 16. sin(x). 2*length(x)))) CI$col <. CI = CI. by = 0. y.seq(0.10). cex = 2.4. sin(x).NA # Some points have no CI CI$x[c(2.with(grid. pch = 16. colvar = cv.74 Scatter plots x <. data = c(rep(0. clab = "cos". sin(x).list(lwd = 2) CI$x <. pch = 16.

anom. 0. zlim = oxlim. main = "Oxygen saturation along ship track".month)) # long-term moving average of anomaly ff <. pch = 16. ylab = "")) 75 . NAcol = "grey". xlab = "longitude". las = 1.c( 11.7. 6. xlab = "longitude". main = "Oxygen saturation".. contour = TRUE. type = "h". col = "black". rep(1/ff. cex = 2. -1. cex = 2.1. "lightblue").data. use same zrange. 1)) # room for colorkey by setting colkey = list(plot = FALSE) # contour plot of the ocean's bathymetry Depth <. sides = 2) with (sunspot.frame(year = time(sunspot.1].month).2. pch = 16. ylab = "latitude".8) lat <.-3. main = "sunspot anomaly". colkey = list(plot = FALSE)) # add data to image.5) O2sat <. 85.mean(sunspot.c( 90.-14. add = TRUE.filter(sunspot$anom.month .Hypsometry$z Depth[Depth > 0] <. ff).9. x = Oxsat$lon. 95. y = Oxsat$lat.NA contour2D(z = Depth.rm = TRUE) image2D(z = Oxsat$val[.-9. x = lon. anom = sunspot. x = lon. col = c("pink".1]. colvar = anom > 0. by = 2000)..c(-19. clab = "%") ## ======================================================================= ## scatter2D for time-series plots ## ======================================================================= # Plotting sunspot 'anomalies' sunspot <. levels = seq(-6000. lines2D(year. ylab = "latitude".100 sunspot$ma <.45. y = lat. with a color key scatter2D(colvar = O2sat. 100) # add to image. -4.range(Oxsat$val[. colkey = FALSE) ## ======================================================================= ## Scatter on a contourplot ## ======================================================================= par(mfrow = c(1.8.0. clim = oxlim. add = TRUE. y = Hypsometry$y. colkey = FALSE. 92. xlab = "year". x = Hypsometry$x. y = lat. 0.Scatter plots oxlim <. clab = "%") # (imaginary) measurements at 5 sites lon <. -8. na. avoid adding a color key scatter2D(colvar = O2sat.

pmat A 4 x 4 viewing transformation matrix. colvar = Rape.76 trans3D lines2D(sunspot$year. such matrices are returned by any of the 3-D plotting functions from package plot3D and by persp(). y. adj = 0. with x. add = TRUE.y. that projects 3-D elements to 2 dimensions. Value A list with two components: • x. # lines(sunspot$year. ylab = "Assault". main = "USA arrests". z Vectors. colvar = Rape. # main = "sunspot". cex = 0.. Usage trans3D (x.6.5. plot(year. y = Assault + 5. sunspot$ma) ## ======================================================================= ## text2D ## ======================================================================= with(USArrests. anom. y the projected 2-D coordinates of the 3-D input x. font = 2)) with(USArrests. z . # col = c("pink". pch = 16. y = Assault. matrices. las = 1)) # but this does not work due to NAs. suitable for projecting the 3D coordinates (x. text2D(x = Murder. y. labels = rownames(USArrests). z. xlab = "Murder". colkey = FALSE)) # reset plotting parameters par(mfrow = pm) trans3D Transformation of 3D elements Description trans3D is the plot3D equivalent of trans3d..t). clab = "Rape".z. arrays. y and z-values.z) into the 2D plane using homogeneous 4D coordinates (x. type = "h". add = TRUE) # The same #with (sunspot. "lightblue")[(anom > 0) + 1]. sunspot$ma. pmat) Arguments x.y. y. scatter2D(x = Murder.

colkey = FALSE) # add line XY <. y.perspbox (z = diag(2)) XY <.trans3D(x = runif(30).trans3D 77 In contrast to trans3d. cex = 3.y <. 1).z <. z are matrices or arrays. 0. col = "darkblue") .scatter3D(M$x. lwd = 2. pmat = pmat) polygon(XY. z)) # plot result pmat <. 1). surf3D. col = "blue") ## ======================================================================== ## Example 2 ## ======================================================================== pmat <. pmat = pmat) lines(XY. trans3D the returned values x and y will be of the same class and dimensions as the input x and y. 1) # plot a 3-D mesh (M <. pch = "+". slice3D. If inputted x. y = c(-1.c(-1 .mesh(x. M$y. y.trans3D(x = c(-1. y = runif(30). z = runif(30). 1). so will the projected coordinates be. Author(s) Karline Soetaert <karline.soetaert@nioz. Examples ## ======================================================================== ## 3-D mesh ## ======================================================================== x <. M$z.nl> See Also scatter3D. z = c(-1.

25 Hypsometry. 22. 8 alpha. 42 contour3D (3-D contours). segments. 20 3-D data set. 63 Scatter plots. 15. 3 box3D (3-D arrows. rectangles). 46 Color key legend. 3. boxes. 13 box3D. 65 Hypsometry (2-D data set). 46 colorRamp. 60. 63 arrows3D (3-D arrows. rectangles). 4 2D image and contour plots. 33 3-D volume visualisation. segments. 13 arrows3D. 13 colkey. 50 Composite plots. 46 Colors. 13 3-D contours.col (Colors). 13 3-D contours. rectangles. 20. 51 colorRampPalette. 50 arrows. polygons. polygons. 33 3-D volume visualisation. 6 contour3D. 41. 34 contour2D. 67 colkey (Color key legend). 3. 6 3-D arrows. polygons. polygons. 6 3-D arrows. boxes. 50 Composite plots. 25 3-D surfaces. 20 createisosurf (3-D volume visualisation). boxes. rectangles). 4 78 . 40 contour. 29. polygons. 15. rectangles). 54 computeContour3d. 47 border3D. 7. rectangles. 6–9. 62 Perspective box. 3 contour2D (2D image and contour plots). 26. 54 images in 3D frame. 16 arrows2D. segments. 59 Mesh generation. 39 createvoxel (3-D volume visualisation). 4 2D image and contour plots. 27. 20 3-D perspectives.interactive. 2 hist3D (3-D perspectives). 3 border3D (3-D arrows. 2 2-D data set. 50 hist3D.col (Colors). boxes. 3 arrows2D (3-D arrows. boxes.col. getplist (Composite plots). 50 gg2. 34. 20. segments. 66 trans3D. segments. 76 ∗Topic package plot3D-package. 3 gg. 3. boxes. 39 13 axis. 23 ∗Topic hplot 2-D data set.col (Colors). 64. 39 dev. 39 Color key legend.Index ∗Topic datasets 3-D data set. 51 Colors. 23 3-D perspectives. 54 gg. 25 3-D surfaces. polygons. segments.

36. 13 ribbon3D. segments. 26. 33 text2D. rectangles). 35. 6 image3D (images in 3D frame). 65. 13 rect3D. 39 slicecont3D. 3. boxes. 29. boxes. 3. 3. 54 points2D (Scatter plots). 20. 62 Mesh generation. 39. 3 rect3D (3-D arrows. 50 jet2. 2. 42. 39 jet. 8 persp. 4. 16. 63. 66 segments. 15. 54 setplist (Composite plots). 42. 2. 63. 24. 2. 29 text3D (Scatter plots). 54. rectangles). segments. 29.plist (Composite plots). 15. boxes.col (Colors). 63 Perspective box. 2 lines3D (Scatter plots). 66 polygon. 77 surf3D (3-D surfaces). 16. 55 polygon2D. 54 slice3D. 59 ImageOcean. 66 text3D. 34–36. 3. 27. 6–9 image2D.col (Colors). 66. 66 lines3D. segments. 3. 3 polygon3D (3-D arrows. 2 ribbon3D (3-D perspectives). boxes. 27. 69 mesh (Mesh generation). 40. 3 segments2D (3-D arrows. 13 79 polygon3D. 63 plot. 66 points3D. 9. 60. 43 Oxsat (3-D data set). 66 scatter3D. 21. 9 rect2D. 65. 65. 26. 69 plotdev (Composite plots). 68 perspbox (Perspective box). 13 segments3D.INDEX image. 54 plot3D (plot3D-package). 50 rasterImage. 4 images in 3D frame. 16. 39 spheresurf3D. 25 perspbox. 16 segments2D. segments. 67 jet. 3.col (Colors).col. polygons. 13 selectplist (Composite plots). 25 Scatter plots. 21. polygons. 68. 20. 65. 3. 61 image2D (2D image and contour plots). 68 persp3D (3-D perspectives). 2 points3D (Scatter plots). boxes.col. 43. 35. segments. 21. 65. segments. 21. 66 mesh. 3 polygon2D (3-D arrows. 16. 63. 61. 8. polygons. polygons. 9 ImageOcean (2-D data set). 2. boxes. 61. 9. 40–42. 3 text2D (Scatter plots). 34–36. 42. 66 scatter2D. 3. 3 rect2D (3-D arrows. 28. 3 ramp. 23 par. 2 isosurf3D (3-D volume visualisation). 28. 33 surf3D. 66 scatter2D (Scatter plots). rectangles). 64. 15. 15. 8. 3 segments3D (3-D arrows. 76 persp3D. 50 lines2D (Scatter plots). 67–69. 60. rectangles). 61. 66 . 41. 35. 2 plotdev. 3. rectangles). 8. polygons. 2 slicecont3D (3-D volume visualisation). 54. 3 spheresurf3D (3-D surfaces). 9. 59 isosurf3D. 2. 25–29. 8. 9. 13 ramp. 77 slice3D (3-D volume visualisation). polygons. 60. 62 Oxsat. 9. 2 plot3D-package. 54. 77 scatter3D (Scatter plots). 61. rectangles). 41.

3. 21. 15. 39 INDEX . 39 voxel3D. 69. 76. 76 trans3d. 61. 60. 16. 77 triangle3D (3-D volume visualisation). 54. 42. 28. 68. 36. 65. 21. 35. 68 voxel3D (3-D volume visualisation).80 trans3D.