stars_3d: Draw stars per group

Description Usage Arguments See Also Examples

View source: R/rgl_group_representation.R

Description

Compute and draw stars (centroid with links) for each group in a rgl device.

Usage

1
2
3
4
5
stars_3d(x, y, z, groups, group_color = rainbow(nlevels((groups))),
  centroid_color = NULL, centroid_radius = 0.05, centroid_alpha = 0.5,
  link_color = NULL, link_width = 1, link_alpha = 1, 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.

centroid_color

A color or a vector of colors to be used in group centroid. If NULL, group_color is used.

centroid_radius

Numeric, the radius of the spheres used to represent group centroids (spheres3d).

centroid_alpha

Numeric, the centroids alpha (rgl.material).

link_color

A color or a vector of colors to be used in links between observations and centroid in each group. If NULL, group_color is used.

link_width, link_alpha

Numeric, the link width and alpha parameters (segments3d, rgl.material).

label_color

A color or a vector of colors to be used in group labels. If NULL, group_color is used.

label_cex, label_family, label_font, label_adj, label_alpha

The text parameters and the alpha of the group labels (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

star_3d

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
42
43
44
45
46
## 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, zoom = 0.75)

# 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 stars
stars_3d(modIris[,1], modIris[,2], modIris[,3],
              groups = modIris$Species,
              group_color = c("purple","green","red","blue"),
              label_adj = list(c(-0.25, 0.5),
                               c(-0.5, 1.5),
                               c(-0.3, 1.2),
                               c(-0.3, 1.5)))

remove(modIris)


## End(Not run)

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