Description Usage Arguments Examples
RGL scatter plot.
rgl_scatter(): quick scatter plot using rgl
rgl_add_axes(): Add axes to an RGL plot
get_colors(): Get colors for the different levels of a factor variable.
rgl_add_ellipses(): Add an ellipse of concentration.
rgl_add_linear_planes(): Add regression planes
rgl_group_labels(): Show the label of each group
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | rgl_scatter(x, y = NULL, z = NULL, groups = NULL, sphere.size = 1,
point.col = "grey", group.col = NULL, add.ellipse = FALSE,
add.reg.planes = FALSE, show.group.labels = TRUE, data.scale = FALSE,
show.bbox = TRUE, ...)
rgl_add_axes(x, y = NULL, z = NULL, axis.col = c("grey", "grey", "grey"),
show.axis.lab = FALSE, xlab = NULL, ylab = NULL, zlab = NULL,
show.plane = TRUE, plane.col = "grey", show.bbox = TRUE,
bbox.col = c("#333377", "black"), show.ticks = FALSE, xlim = NULL,
ylim = NULL, zlim = NULL, ...)
get_colors(groups, group.col = palette()[-1])
rgl_add_ellipses(x, y = NULL, z = NULL, groups = NULL,
conf.level = 0.95, ellipse.col = NULL, ellipse.fill = TRUE,
ellipse.grid = FALSE, ...)
rgl_add_linear_planes(x, y = NULL, z = NULL, groups = NULL,
surface.col = "steelblue", grid.col = "black", plane.fill = TRUE,
plane.grid = FALSE, droplines = TRUE, smooth = FALSE, ...)
rgl_group_labels(x, y = NULL, z = NULL, groups, group.col = "black",
cex = 2, ...)
|
x,y,z |
the coordinates of the points to draw. Both y and z can be left at NULL. x can be a data frame or a formula zvar ~ xvar + yvar |
groups |
a factor variable specifing the groups of the observations |
sphere.size |
the size of the spheres |
point.col |
the color to be used for the points when groups = NULL |
group.col |
a vector containing the names of colors to be used for each group |
add.ellipse |
logical value. If TRUE, an ellipse is added around points |
add.reg.planes |
logical value. If TRUE add regression planes |
show.group.labels |
logical value. If TRUE, group labels are shown |
data.scale |
logical value. If TRUE, the coordinates (x, y, z) is scaled so that the minimum of each axis = 0 and the maximum = 1 |
show.bbox |
add the bounding box decoration. |
... |
other arguments to be passed to the function rgl_add_axis(), rgl_add_ellipses(), rgl_add_linear_planes() or rgl_group_labels(). |
axis.col |
colors for the 3 axes. |
show.axis.lab |
If TRUE show axis labels. |
xlab,ylab,zlab |
labels to be used for x, y, and z axes, respectively. |
show.plane |
If TRUE, show axis planes at y = 0. |
plane.col |
the color to be used for plane. Default is "grey". |
bbox.col |
the bounding box colors. The first color is the the background color; the second color is the color of tick marks |
show.ticks |
if TRUE, show ticks |
xlim,ylim,zlim |
the limits for x, y and z axes, respectively |
conf.level |
The confidence level of a simultaneous confidence region. This is used to control the size of the ellipsoid. |
ellipse.col |
a vector of color(s) to be used for the ellipse(s) |
ellipse.fill |
a logical value. If TRUE, fills the plotted ellipse(s) with ellipse.col |
ellipse.grid |
a logical value. If TRUE, adds grid lines on the ellipse(s) |
surface.col |
color to be used for regression plane surfaces. |
grid.col |
color for grids in the regression planes |
plane.fill |
logical value; if TRUE the regression planes are filled |
plane.grid |
logical value. If TRUE grids are shown |
droplines |
logical values. If TRUE, droplines are shown from regression surfaces to the points. |
smooth |
logical value. If TRUE, smoothed regression planes are drawn. |
cex |
the size of text 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 47 48 | # Load dataset
data(iris)
x <- iris$Sepal.Length
y <- iris$Petal.Length
z <- iris$Sepal.Width
library("rgl")
# Quick scatter plots
rgl_scatter(iris, groups = iris$Species)
# Scale data
rgl_scatter(iris, groups = iris$Species, data.scale = TRUE)
# Remove the bounding box
rgl_scatter(iris, groups = iris$Species, show.bbox = FALSE)
# Add ellipses
rgl_scatter(iris, groups = iris$Species,
show.bbox = FALSE, add.ellipse = TRUE)
# Scatter plot with axes
# +++++++++++++++++
rgl_init()
rgl.spheres(x, y, z, r = 0.2, color = "yellow")
rgl_add_axes(x, y, z)
# Change the color by groups
# +++++++++++++++++
rgl_init()
rgl.spheres(x, y, z, r = 0.2, color = get_colors(iris$Species))
rgl_add_axes(x, y, z, show.bbox = TRUE)
aspect3d(1,1,1)
# Add ellipses
# ++++++++++++++++++
rgl_init()
rgl.spheres(x, y, z, r = 0.2, color = "#D95F02")
rgl_add_axes(x, y, z, show.bbox = TRUE)
rgl_add_ellipses(x, y, z, ellipse.col = "#D95F02")
aspect3d(1,1,1)
# Regression planes
# +++++++++++++++++++
rgl_init()
rgl.spheres(x, y, z, r = 0.2,
color = get_colors(iris$Species, c("red", "blue", "green")))
rgl_add_axes(x, y, z, show.bbox = TRUE)
rgl_add_linear_planes(x, y, z, groups = iris$Species,
surface.col = c("red", "blue", "green"))
aspect3d(1,1,1)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.