R中Mathematica的RegionPlot3D()相当于什么?

时间:2014-01-27 00:09:02

标签: r

我想生成一个3D图,显示代表不等式组合的3D区域。在Mathematica中,我使用RegionPlot3D()

RegionPlot3D[
 x^2 + y^2 + z^2 < 1 && x^2 + y^2 < z^2, {x, -1, 1}, {y, -1, 
  1}, {z, -1, 1}, PlotPoints -> 35, PlotRange -> All]

生成:

enter image description here

我怎么能在R?中做到这一点?

1 个答案:

答案 0 :(得分:0)

这使情节:

#equivalent to range and plotpoints
x <- seq(-1, 1, by=0.01)
y <- seq(-1, 1, by=0.01)
z <- seq(-1, 1, by=0.01)

df <- setNames(expand.grid(x, y, z), c("x", "y", "z"))
df <- transform(df, ueq = (x^2 + y^2 + z^2 < 1) & (x^2 + y^2 < z^2))
df$color <- ifelse(df$ueq == TRUE, "green" , "red")

#use this rgl
require(rgl)
with(df[df$ueq == TRUE, ], plot3d(x=x, y=y, z=z, col=color, type="p", size=5))
grid3d(c("x", "y+", "z"))
相关问题