Description Usage Arguments See Also Examples
View source: R/rgl_group_representation.R
Compute and draw stars (centroid with links) for each group in a rgl device.
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)
|
x, y, z |
Numeric vectors representing point coordinates. |
groups |
A factor vector of length |
group_color |
A vector of length |
centroid_color |
A color or a vector of colors to be used in
group centroid. If NULL, |
centroid_radius |
Numeric, the radius of the spheres used to
represent group centroids ( |
centroid_alpha |
Numeric, the centroids alpha
( |
link_color |
A color or a vector of colors to be used in
links between observations and centroid in each group.
If NULL, |
link_width, link_alpha |
Numeric, the link width and alpha parameters
( |
label_color |
A color or a vector of colors to be used in
group labels. If NULL, |
label_cex, label_family, label_font, label_adj, label_alpha |
The text
parameters and the alpha of the group labels ( |
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.