Perspective box | R Documentation |
perspbox
draws a box and labels, and makes space for a colorkey (if any).
perspbox (x = seq(0, 1, length.out = nrow(z)),
y = seq(0, 1, length.out = ncol(z)), z,
bty = c("b", "b2", "f", "g", "bl", "bl2", "u", "n"), ...,
col.axis = "black", col.panel = NULL, lwd.panel = 1,
col.grid = NULL, lwd.grid = 1,
phi = 40, theta = 40, col = NULL,
colkey = NULL, plot = TRUE)
x , y |
Vectors with x and y values. It is sufficient to pass the
ranges of the x- and y-values, as they will not be drawn.
If |
z |
Matrix or vector with z-values. If |
bty |
The type of the box; only effective if the persp
argument |
col.axis , col.panel , col.grid |
The color of the axis line, of the
axis panel or of the grid lines. Only used if |
lwd.panel , lwd.grid |
The width of the panel border or of the
grid lines. Only used if |
theta , phi |
The angles defining the viewing direction.
|
col |
Colors to be used for coloring the |
colkey |
A logical, The default is to draw the color key on side = 4, i.e. in the right margin.
If |
plot |
Logical. If |
... |
additional arguments passed to persp. The following persp arguments can be specified:
Arguments The arguments after ... must be matched exactly. |
The arguments xlim
, ylim
, zlim
only affect the axes.
All objects will be plotted, including those that fall out of these ranges.
To select objects only within the axis limits, use plotdev.
The predefined box types bty
are defined as follows:
“f”: all panels are shown and transparent, also the persp default.
“b”: only backward panels shown.
“b2”: as “b” with col.grid = "grey"
.
“g”: only backward panels shown; col.panel = grey(0.95)
,
col.axis = "grey"
,
lwd.grid = 2
and col.grid = "white"
.
“bl”: only backward panels shown; col.panel = "black"
,
col.axis = "grey"
,
lwd.grid = 2
and col.grid = "white"
.
“n”: no box is drawn.
Function perspbox
returns the viewing transformation matrix.
See trans3D.
Karline Soetaert <karline.soetaert@nioz.nl>
persp3D, scatter2D, surf3D for examples where box types different than the default are used.
Hypsometry for an example where colored axis-panels are added to a
figure started with perspbox
.
# save plotting parameters
pm <- par("mfrow")
pmar <- par("mar")
## ========================================================================
## The 4 predefined box types
## ========================================================================
par(mfrow = c(2, 2), mar = c(1, 1, 1, 1))
# box type with only backward panels
perspbox(z = volcano, bty = "b", ticktype = "detailed", d = 2,
main = "bty = 'b'")
# box as in 'persp'
perspbox(z = volcano, bty = "f", ticktype = "detailed",
d = 2, main = "bty = 'f'")
# back panels with gridlines, detailed axes
perspbox(z = volcano, bty = "b2", ticktype = "detailed",
d = 2, main = "bty = 'b2'")
# ggplot-type, simple axes
perspbox(z = volcano, bty = "g",
d = 2, main = "bty = 'g'")
## ========================================================================
## A user-defined box
## ========================================================================
par(mfrow = c(1, 1))
perspbox(z = diag(2), bty = "u", ticktype = "detailed",
col.panel = "gold", col.axis = "white",
scale = FALSE, expand = 0.4,
col.grid = "grey", main = "user-defined")
# restore plotting parameters
par(mfrow = pm)
par(mar = pmar)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.