rgl

How to plot a three dimensional sphere in R based on center and radius?

和自甴很熟 提交于 2019-12-07 18:20:01
问题 How can one plot a sphere in R by providing a center point and a radius? For example, something like this: sphere_3d(center=c(1,1,1), r=2)) The plot would appear on a three dimensional coordinate system. 回答1: Try spheres3d in the rgl package for an interactive plot: library(rgl) spheres3d(x = 1, y = 1, z = 1, radius = 1) There are many other ways, so what's going to be useful needs more input. 回答2: Adapted from @mdsummer's answer, this also adds axes. library(rgl) open3d() # create new plot

Using “expression” in R rgl axis labels

只谈情不闲聊 提交于 2019-12-07 05:58:27
问题 Do the rgl routines accept the use of "expression" for Greek letters and super/sub script for axis labelling? Something like xlab=(expression(paste("Lyman ",alpha,))) works perfectly well in a normal plot call but just seems to display "(paste("Lyman ",alpha,)" as my axis label in plot3d and decorate3d. If not, how can I add these characters to my 3D scatterplots generated using plot3d? 回答1: On my system (OSX 10.7.5, R 3.1.2) I get an alpha as xlab with: require(rgl) plot3d(1,1,1,xlab

Make a 3D rendered plot of time-series

不想你离开。 提交于 2019-12-07 04:00:28
I have a set of 3D coordinates (below - just for a single point, in 3D space): x <- c(-521.531433, -521.511658, -521.515259, -521.518127, -521.563416, -521.558044, -521.571228, -521.607178, -521.631165, -521.659973) y <- c(154.499557, 154.479568, 154.438705, 154.398682, 154.580688, 154.365189, 154.3564, 154.559189, 154.341309, 154.344223) z <- c(864.379272, 864.354675, 864.365479, 864.363831, 864.495667, 864.35498, 864.358582, 864.50415, 864.35553, 864.359863) xyz <- data.frame(x,y,z) I need to make a time-series plot of this point with a 3D rendering (so I can rotate the plot, etc.). The plot

3D interactive surface plot with spatial data

岁酱吖の 提交于 2019-12-06 14:15:35
I would like to create an interactive 3D surface plot of depths in a lake, ideally using the plotly or rgl libraries. I have extracted my data from a SpatialLinesDataFrame of contour lines in Gauss-Krueger/EPSG:31468 CRS, i.e. metric units. Now each contour line produces a set of coordinates with the same depth value. The resulting data frame is rather large, but looks something like this: set.seed(41) xx <- rnorm(100,4448929,100) yy <- rnorm(100,5308097,100) zz <- c(rep(-10,10),rep(-20,10),rep(-30,10),rep(-40,10),rep(-50,10),rep(-60,10),rep(-70,10),rep(-80,10),rep(-90,10),rep(-100,10)) df <-

Plot ellipse3d in R plotly?

允我心安 提交于 2019-12-06 11:32:49
Package rgl includes a very useful function ellipse3d , which can return an ellipsoid that cover like 95% percent of the points in 3D. Then this object can be used in rgl::plot3d to plot it out. My question is that is it possible to convert the output of ellipse3d to something that can be plotted through js plotting packages like plotly? library(rgl) dt <- cbind(x = rnorm(100), y = rnorm(100), z = rnorm(100)) ellipse <- ellipse3d(cov(dt)) plot3d(dt) plot3d(ellipse, add = T, color = "red", alpha = 0.5) Then what can I do to plot the ellipsoid through plotly? You can extract the coordinates of

3d scatterplot in R using rgl plot3d - different size for each data point?

我只是一个虾纸丫 提交于 2019-12-06 07:52:42
问题 I am using plot3d(x,y,z, col=test$color, size=4) to plot a 3d scatterplot of my dataset with R, but with rgl the size argument only takes one size. Is it possible to have different sizes for each data point, perhaps with another library, or is there a simple workaround? Thanks for your ideas! 回答1: Here's a work-around along the same lines suggested by Etienne. The key idea is to set up the plot, then use a separate call to points3d() to plot the points in each size class. # Break data.frame

Exporting rgl.snapshot and rgl.postscript fails

孤街醉人 提交于 2019-12-06 05:23:44
I am currently using the rgl package for some data representation. Here's my command mypath("directory") png(file=mypath, res=600, width=10.5, height= 10.5,units="in",bg = "transparent") require(rgl) set.seed(1) df <- data.frame(replicate(4,sample(1:200,1000,rep=TRUE))) colnames(df) <- c("var1","var2","var3","var4") plot3d(x=df$var1, y=df$var2, z=df$var3, col=as.numeric(df$var4), size=0.5, type='s',xlab="var1",ylab="var2",zlab="var3") rgl.snapshot(mypath) The command above works and produces a tiny image, which I wasn't able to make bigger, or increase its resolution (to 600). I have also

RGL package for R compile error

我的梦境 提交于 2019-12-06 05:07:45
Attempting to compile rgl for r on arch linux x86_64. I copied just the error portion of the installation. This has occurred after I recently updated R. Any idea how to solve this? g++ -I/usr/include/R/ -DNDEBUG -DHAVE_PNG_H -I/usr/include/libpng16 -DHAVE_FREETYPE -Iext/ftgl -I/usr/include/freetype2 -Iext -D_FORTIFY_SOURCE=2 -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong --param=ssp-buffer-size=4 -fvisibility=hidden -fpic -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong --param=ssp-buffer-size=4 -c init.cpp -o init.o In file included from /usr/include/freetype2

error: installation of package ‘rgl’ had non-zero exit status

女生的网名这么多〃 提交于 2019-12-06 04:01:00
问题 I would like to use plot 3D so I was trying to download rgl but whenever I am trying to install this, I am getting this error in rgl package installation. So can you please suggest me something. install.packages("rgl", dependencies=TRUE) Installing package into ‘/root/R/x86_64-unknown-linux-gnu-library/3.2’ (as ‘lib’ is unspecified) --- Please select a CRAN mirror for use in this session --- trying URL 'http://cran.skazkaforyou.com/src/contrib/rgl_0.95.1247.tar.gz' Content type 'application/x

How to plot a three dimensional sphere in R based on center and radius?

蓝咒 提交于 2019-12-05 22:44:46
How can one plot a sphere in R by providing a center point and a radius? For example, something like this: sphere_3d(center=c(1,1,1), r=2)) The plot would appear on a three dimensional coordinate system. Try spheres3d in the rgl package for an interactive plot: library(rgl) spheres3d(x = 1, y = 1, z = 1, radius = 1) There are many other ways, so what's going to be useful needs more input. Jeromy Anglim Adapted from @mdsummer 's answer, this also adds axes. library(rgl) open3d() # create new plot spheres3d(x = 1, y = 1, z = 1, radius = 1) # produce sphere axes3d() # add x, y, and z axes Take a