0
votes

I would like to plot two planes in a 3D plot. I have tried persp3d and it generates two planes. But instead of the whole two planes, I just want to show parts of them divided by the intersection line, i.e, "left" part of the blue plane, and "upper" part of the red plane. I tried xlim, ylim, but it seems my lims are not single values, but functions.

library(rgl)
x <- seq(-10, 10, length = 30)
y <- x
region = expand.grid(x=x, y=y)
z1 = region$x+2*region$y + 2
z2=3*region$x+region$y
persp3d(x,y,z1,col="steelblue")
persp3d(x,y,z2,col="red",add=TRUE)
2

2 Answers

0
votes

 grid = mesh(x,y)
 z = with(grid,ifelse(x+2*y>3*x+y,x+2*y,3*x+y))
 persp3D(z = z, x = x, y = y,col = NULL)
0
votes
for (i in 1:900){
z[i] = ifelse(region$x[i]+2*region$y[i] + 2 > 
3*region$x[i]+region$y[i],region$x[i]+2*region$y[i] + 2,3*region$x[i]+region$y[i])}
persp3d(x,y,z,col="steelblue")

This is inspired by Huang Rui's suggestion