Description Usage Arguments Details Author(s) See Also Examples

`image2Drgl`

plots an image in rgl.

`contour2Drgl`

creates a contourplot in rgl.

`scatter2Drgl`

creates a scatterplot (lineplot, points, ...) in rgl.

`points2Drgl`

is shorthand for `scatter2Drgl(..., type = "p")`

`lines2Drgl`

is shorthand for `scatter2Drgl(..., type = "l")`

`arrows2Drgl`

and `segments3D`

plot arrows and segments in rgl.

`text2Drgl`

plots labels in rgl.

These functions were implemented for their side effect that rgl plots can be zoomed, translocated, rectangular selections taken.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | ```
image2Drgl (z, x = seq(0, 1, length.out = nrow(z)),
y = seq(0, 1, length.out = ncol(z)), ...,
col = NULL, NAcol = "white", breaks = NULL, border = NA,
facets = TRUE, colkey = NULL, contour = FALSE,
smooth = FALSE, clim = NULL, clab = NULL, shade = NA,
inttype = 1, dz = 0, add = FALSE)
contour2Drgl (z, x = seq(0, 1, length.out = nrow(z)),
y = seq(0, 1, length.out = ncol(z)), ...,
col = NULL, colkey = NULL, clim = NULL, clab = NULL, dz = 0.1,
add = FALSE)
scatter2Drgl (x, y, colvar = NULL, ...,
col = NULL, NAcol = "white", breaks = NULL, colkey = NULL,
clim = NULL, clab = NULL, CI = NULL, dz = 0.1, add = FALSE)
text2Drgl (x, y, labels, colvar = NULL, ...,
col = NULL, NAcol = "white", breaks = NULL, colkey = NULL,
clim = NULL, clab = NULL, dz = 0.1, add = FALSE)
arrows2Drgl (x0, y0, x1, y1, colvar = NULL, ...,
col = NULL, NAcol = "white", breaks = NULL, colkey = NULL,
clim = NULL, clab = NULL, type = "simple", dz = 0.1, add = FALSE)
segments2Drgl (x0, y0, x1, y1, colvar = NULL, ...,
col = NULL, NAcol = "white", breaks = NULL, colkey = NULL,
clim = NULL, clab = NULL, dz = 0.1, add = FALSE)
rect2Drgl (x0, y0, x1, y1, colvar = NULL, ...,
col = NULL, NAcol = "white", breaks = NULL, colkey = NULL,
clim = NULL, clab = NULL, dz = 0.1, add = FALSE)
lines2Drgl(x, y, ...)
points2Drgl(x, y, ...)
``` |

`x, y ` |
Vectors with the x- and y- values. |

`z ` |
The variable used for coloring the image plot, or containing the values to be plotted for the contour plot. |

`x0, y0 ` |
coordinates of points |

`x1, y1 ` |
coordinates of points |

`colvar ` |
The variable used for coloring the scatter plot or the arrows.
If |

`labels ` |
The text to be written. A vector of length equal to length of x, y. |

`col ` |
Color palette to be used for the |

`NAcol ` |
Color to be used for |

`breaks ` |
a set of finite numeric breakpoints for the colors; must have one more breakpoint than color and be in increasing order. Unsorted vectors will be sorted, with a warning. |

`border ` |
The color of the lines drawn around the surface facets.
The default, |

`facets ` |
If |

`shade ` |
the degree of shading of the surface facets. Values of shade close to one yield shading similar to a point light source model and values close to zero produce no shading. Creates the illusion of perspective. See persp. |

`contour ` |
If |

`smooth ` |
Logical, specifying whether Gouraud shading (smooth)
or flat shading should be used. (if |

`colkey ` |
A logical, NULL (default), or a list with parameters for the
color key (legend). Not all arguments from the original colkey function
from |

`clim ` |
Only if |

`clab ` |
Only if |

`inttype ` |
The interpolation type to create the polygons, either
interpolating the |

`CI ` |
A |

`type ` |
The type of the arrow head, one of |

`dz ` |
The 'layer depth', The z-position is defined as 1 + dz. |

`add ` |
Logical. If |

`...` |
additional arguments passed to the plotting methods.
The following persp arguments can be specified:
Also the arguments The arguments after ... must be matched exactly. |

The first step in 2D rgl plotting consists in calling a 3-D function from package `plot3D`

with argument `plot`

set to `FALSE`

.

`image2Drgl`

and `contour2Drgl`

call the image3D and contour3D
functions of R-package `plot3D`

, with `colvar`

equal to `z`

.
Functions `scatter2Drgl`

and `arrows2Drgl`

call scatter3D and arrows3D.

The z value argument to the 3-D functions is set equal to `1 + dz`

;
For `contour3D`

, `scatter3D`

and `arrows3D`

, it is by default equal to `1.1`

,
while for `image3D`

it is `1`

.
This way, contours, points, segments and arrows will be drawn on top of the image.

The next step is to create a 3-D rgl plot, by calling plotrgl.
After that, the viewing arguments are set equal to
`view3d(phi = 0, fov = 0)`

, i.e. the plot is viewed at from the top.

The actions of the mouse on the plots is to zoom (left, middle), and to move it (right key).

Karline Soetaert <karline.soetaert@nioz.nl>

image3D, contour3D, scatter3D, segments3D, text3D and arrows3D on which the functions are based.

image2D, contour2D, scatter2D, segments2D,
text2D, arrows2D
for `plot3D`

's functions, to plot in ordinary R graphics.

cutrgl for cutting a rectangular region from the 2D plot.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | ```
## =======================================================================
## image and points
## =======================================================================
image2Drgl(z = volcano, contour = TRUE, main = "volcano")
scatter2Drgl(x = seq(0, 1, by = 0.2), y = seq(0, 1, by = 0.2),
cex = 3, add = TRUE)
## Not run:
cutrgl() # select a rectangle
uncutrgl()
## End(Not run)
## =======================================================================
## scatter points, and lines
## =======================================================================
scatter2Drgl(cars[,1], cars[,2], xlab = "speed", ylab = "dist")
## Not run:
cutrgl()
## End(Not run)
lc <- lowess(cars)
scatter2Drgl(lc$x, lc$y, type = "l", add = TRUE, lwd = 4)
## Not run:
cutrgl()
uncutrgl()
## End(Not run)
## =======================================================================
## confidence intervals
## =======================================================================
x <- sort(rnorm(10))
y <- runif(10)
cv <- sqrt(x^2 + y^2)
CI <- list(lwd = 2)
CI$x <- matrix (nrow = length(x), data = c(rep(0.125, 2*length(x))))
scatter2D(x, y, colvar = cv, pch = 16, cex = 2, CI = CI)
scatter2Drgl(x, y, colvar = cv, cex = 2, CI = CI)
## =======================================================================
## arrows
## =======================================================================
arrows2Drgl(x0 = 100*runif(30), y0 = runif(30), x1 = 100*runif(30),
y1 = runif(30), length = 0.1*runif(30), col = 1:30, angle = 15:45,
type = c("simple", "triangle"), lwd = 2)
x0 <- 1:30
x1 <- 2:31
arrows2Drgl(x0 = x0, y0 = sin(x0), x1 = x1, y1 = sin(x1),
colvar = x1, lwd = 2)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.