Description Usage Arguments Value Examples
Calculates the joint density of two variables and then plots them using persp.
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 | dens2d(
x,
y,
xlim = range(x),
ylim = range(y),
zlim = range(z, na.rm = TRUE),
grid.size = 50,
xlab = " x ",
ylab = " y ",
zlab = "Joint PDF",
main = NULL,
sub = NULL,
theta = 40,
phi = 40,
r = exp(1),
d = 1,
scale = TRUE,
expand = 1,
col = .greencolors,
viridis.opt = "D",
border = "#9ba4a91A",
ltheta = -135,
lphi = 15,
shade = NA,
box = TRUE,
axes = TRUE,
nticks = 4,
ticktype = "detailed",
plot = TRUE,
type = "persp"
)
|
x |
the data from which the estimate is to be computed. For the default method a numeric vector: long vectors are not supported. |
y |
the data from which the estimate is to be computed. For the default method a numeric vector: long vectors are not supported. |
xlim |
x-, y- and z-limits. These should be chosen to cover the range of values of the surface |
ylim |
x-, y- and z-limits. These should be chosen to cover the range of values of the surface |
zlim |
x-, y- and z-limits. These should be chosen to cover the range of values of the surface |
grid.size |
The size of the grid. The actual grid size is grid.size^2, since it is of z = x*y dimensions. |
xlab |
titles for the axes. N.B. These must be character strings; expressions are not accepted. Numbers will be coerced to character strings. |
ylab |
titles for the axes. N.B. These must be character strings; expressions are not accepted. Numbers will be coerced to character strings. |
zlab |
titles for the axes. N.B. These must be character strings; expressions are not accepted. Numbers will be coerced to character strings. |
main |
main and sub title, as for title. |
sub |
main and sub title, as for title. |
theta |
angles defining the viewing direction. theta gives the azimuthal direction and phi the colatitude. |
phi |
angles defining the viewing direction. theta gives the azimuthal direction and phi the colatitude. |
r |
the distance of the eyepoint from the centre of the plotting box. |
d |
a value which can be used to vary the strength of the perspective transformation. Values of d greater than 1 will lessen the perspective effect and values less and 1 will exaggerate it. |
scale |
before viewing the x, y and z coordinates of the points defining the surface are transformed to the interval [0,1]. If scale is TRUE the x, y and z coordinates are transformed separately. If scale is FALSE the coordinates are scaled so that aspect ratios are retained. This is useful for rendering things like DEM information. |
expand |
a expansion factor applied to the z coordinates. Often used with 0 < expand < 1 to shrink the plotting box in the z direction. |
col |
the color(s) of the surface facets. Transparent colours are ignored. This is recycled to the (nx-1)(ny-1) facets. The default is a green colored palette. Changing to NULL will use a viridis palette. |
viridis.opt |
A character string indicating the viridis palette variant to use. Four options are available: "magma" (or "A"), "inferno" (or "B"), "plasma" (or "C"), "viridis" (or "D", the default option) and "cividis" (or "E"). |
border |
the color of the line drawn around the surface facets. The default of NA will disable the drawing of borders: this is sometimes useful when the surface is shaded. NULL corresponds to par("fg"). |
ltheta |
if finite values are specified for ltheta and lphi, the surface is shaded as though it was being illuminated from the direction specified by azimuth ltheta and colatitude lphi. |
lphi |
if finite values are specified for ltheta and lphi, the surface is shaded as though it was being illuminated from the direction specified by azimuth ltheta and colatitude lphi. |
shade |
the shade at a surface facet is computed as ((1+d)/2)^shade, where d is the dot product of a unit vector normal to the facet and a unit vector in the direction of a light source. Values of shade close to one yield shading similar to a point light source model and values close to zero produce no shading. Values in the range 0.5 to 0.75 provide an approximation to daylight illumination. |
box |
should the bounding box for the surface be displayed. The default is TRUE. |
axes |
should ticks and labels be added to the box. The default is TRUE. If box is FALSE then no ticks or labels are drawn. |
nticks |
character: "simple" draws just an arrow parallel to the axis to indicate direction of increase; "detailed" draws normal ticks as per 2D plots. |
ticktype |
the (approximate) number of tick marks to draw on the axes. Has no effect if ticktype is "simple". |
plot |
defaults to TRUE. Otherwise, returns a list of x, y, and z. |
type |
Defaults to "persp", for which most of these arguments are used. If "plotly", most of the arguments except col, xlab, ylab, and zlab are ignored. If "contour" the filled.contour function is used and only the col argument is acknowledged. |
either a list or a plot
1 | dens2d(wines$Alcohol, wines$Malic.acid)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.