ellipsoids_3d: Draw ellipsoids per group

Description Usage Arguments See Also Examples

View source: R/rgl_group_representation.R

Description

Compute and draw a labeled ellipsoid for each group in a rgl device. Singleton or groups with less than four observations are drawn as individual spheres.

Usage

1
2
3
4
5
6
7
ellipsoids_3d(x, y, z, groups, group_color = rainbow(nlevels((groups))),
  type = "wire and shade", level = 0.95, singleton_color = NULL,
  singleton_radius = 0.1, wire_color = NULL, wire_alpha = 0.2,
  wire_lit = FALSE, shade_color = NULL, shade_alpha = 0.1,
  shade_lit = FALSE, label_color = NULL, label_cex = 1,
  label_family = "sans", label_font = 2, label_adj = c(-0.25, 0.5),
  label_alpha = 1)

Arguments

x, y, z

Numeric vectors representing point coordinates.

groups

A factor vector of length length(x) containing the group assignation of each point.

group_color

A vector of length nlevels(groups) containing the colors to be used in each group.

type

a character representing the type of ellipsoid filling: "wire", "shade" or "wire and shade" (wire3d, shade3d).

level

the confidence level of a simultaneous confidence region (ellipse3d).

singleton_color, wire_color, shade_color, label_color

The specific colors to be used in each ellipsoid's elements for each group. If not NULL, they override the colors argument.

singleton_radius

the radius of the spheres (spheres3d) used to represent points of groups with three or less points.

wire_alpha, wire_lit

the wire alpha and lit parameters (rgl.material).

shade_alpha, shade_lit

the shade alpha and lit parameters (rgl.material).

label_cex, label_family, label_font, label_adj, label_alpha

the group labels text parameters (text3d, rgl.material). label_adj accepts a single numeric value (horizontal), a numeric vector of length two (horizontal, vertical) or a list of length nlevels(groups) containing the adj values for the specific groups.

See Also

ellipsoid_3d, spheres3d

Examples

 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
## Not run: 

# Use iris data
data("iris")

# introduce fictional singleton species
modIris <- iris
modIris$Species <- as.character(modIris$Species)
modIris <- rbind(modIris, list(6, 1, 2, 3, "outlier"))
modIris$Species <- factor(modIris$Species)

# Initializes the rgl device
rgl_init(theta = 60, phi = 45)

# add axes and bounding box
rgl_format(modIris$Sepal.Length, modIris$Sepal.Width, modIris$Petal.Length,
           axes_titles = c("Sepal length", "Sepal width", "Petal length"),
           show_planes = c("XZ", "XY", "YZ"))

# Add data points
points3d(modIris[modIris$Species == "setosa", 1],
         modIris[modIris$Species == "setosa", 2],
         modIris[modIris$Species == "setosa", 3],
         color = "green")
points3d(modIris[modIris$Species == "versicolor", 1],
         modIris[modIris$Species == "versicolor", 2],
         modIris[modIris$Species == "versicolor", 3],
         color = "red")
points3d(modIris[modIris$Species == "virginica", 1],
         modIris[modIris$Species == "virginica", 2],
         modIris[modIris$Species == "virginica", 3],
         color = "blue")

# Add ellipsoids
ellipsoids_3d(modIris[, 1], modIris[, 2], modIris[, 3],
             groups = modIris$Species,
             group_color = c("purple", "green", "red", "blue"))

remove(modIris)

## End(Not run)

Andros-Spica/biplot2d3d documentation built on June 10, 2020, 1:38 p.m.