我想生成一个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]
生成:
我怎么能在R?中做到这一点?
答案 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"))