![]() #' 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. The values x2, y2 and 圓 corresponds to the 3D coordinates of the line ending point.The values x1, y1 and 圓 are the 3D coordinates of the line starting point.R3D is a collection of generic 3D objects and functions which are described at the end of this article.įor the function rgl.lines(), the arguments x, y, and z are numeric vectors of length 2 (i.e, : x = c(x1,x2), y = c(y1, y2), z = c(z1, z2) ). The rgl package includes also a generic 3D interface named R3D. It allows to interactively rotate, zoom the graphics and select regions. RGL is a 3D graphics package that produces a real-time interactive 3D plot. You’ll learn also how to create a movie of your 3D scene in R. This R tutorial describes, step by step, how to build a 3D graphic using R software and the rgl package. Export the plot into an interactive HTML file.Set the aspect ratios of the x, y and z axes.rgl_add_axes(): A custom function to add x, y and z axes.rgl_init(): A custom function to initialize RGL device.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |