![]() a, b, c: coordinates of the normal to the planeĪ Planes3d() and rgl.planes() draw planes using the parameter ax + by + cz + d = 0. The function planes3d() or rgl.planes() can be used to add regression plane into 3D rgl plot: rgl.planes(a, b = NULL, c = NULL, d = 0. Texts3d(mean(xx),mean(yy), mean(zz), text = group, Shade3d(ellips, col = l, alpha = 0.1, lit = FALSE) Wire3d(ellips, col = "#D95F02", lit = FALSE) Draw the ellipse using the function wired3d():.# Compute and draw the ellipse of concentrationĬentre=c(mean(x), mean(y), mean(z)), level = 0.95) Draw the ellipse using the function shade3d():.The function ellipse3d() returns an object of class mesh3d which can be drawn using the function shade3d() and/or wired3d() This is used to control the size of the ellipsoid. level: The confidence level of a confidence region.centre: The center of the ellipse will be at this position.This defaults to c(1, 1, 1), so no rescaling will be done. scale: If x is a correlation matrix, then the standard deviations of each parameter can be given in the scale parameter.x: the correlation or covariance matrix between x, y and z.It’s also possible to use color palettes from the RColorBrewer package: library("RColorBrewer")Ĭols <- get_colors(iris$Species, brewer.pal(n=3, name="Dark2") ) Rgl.spheres(x, y, z, r = 0.2, color = cols) ![]() #' colors a vector containing the names of #' groups a factor variable containing the groups Rgl.bbox(color=c(l,l), alpha = 0.5,Įmission=l, specular=l, shininess=5,Ī helper function can be used to select automatically a color for each group: #' Get colors for the different levels of Rgl.texts(axes, text = c(xlab, ylab, zlab), color = l, # Add a point at the end of each axes to specify the directionĪxes <- rbind(c(xlim, 0, 0), c(0, ylim, 0), Xlim <- lim(x) ylim <- lim(y) zlim <- lim(z) Rgl_add_axes <- function(x, y, z, l = "grey", # the background color the second color is the color of tick marks # show.bbox : add the bounding box decoration Rgl_add_axes(): A custom function to add x, y and z axes # x, y, z : numeric vectors corresponding to Use c(-max, +max) as the ranges of the axes.Transform the x, y and z variables so that their min = 0 and their max = 1 There are two solutions to handle this situation: Rgl.lines(c(0, 0), c(0, 0), c(min(z),max(z)), color = "green")Īs you can see, the axes are drawn but the problem is that they don’t cross at the point c(0, 0, 0) Rgl.spheres(x, y, z, r = 0.2, color = "yellow") To draw an axis, you should specify the range (minimum and the maximum) of the axis to the function rgl.lines(): # Make a scatter plot ![]() In this case, the argument y and z can be omitted. Note also that, the argument x can be a matrix or a data frame containing, at least, 3 columns corresponding to the x, y and z coordinates, respectively. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |