Reputation: 18229
I ran some simulations exploring a 3D space of parameters and recorded by TRUE or FALSE the presence and absence of a given pattern. Here is some data to make a reproducible example
v1 = 1:12
v2 = c(0.01, 0.1, 1, 10, 100, 1000)
v3 = c(0.001, 0.01, 0.05, 0.1, 2, 10, 20, 100)
data = expand.grid(v1, v2, v3)
names(data) = c("v1", "v2", "v3")
VResponse = c()
for (row in 1:nrow(data)) {if (data$v1[row] > 8 | data$v1[row] < 2) {if (data$v2[row] > 0.1){if (data$v3[row] > 0.1){VResponse[row] = T} else {VResponse[row] = F}} else {VResponse[row] = F}} else {if (data$v2[row] > 10 & data$v3[row] > 0.1){VResponse[row] = T} else {VResponse[row] = F}}}
data = cbind(data, VResponse)
My goal is to make a plot that displays the zones where VResponse
is TRUE and the zones where VResponse
is FALSE. I made 2D plots with plot
and ggplot
by taking into account 2 of the three variables and plotting VResponse
in two different colors (actually plotting the zones using this method). I tried to make a plot in three dimension using plot3d
from the rgl
package but I didn't find it very handy.
In addition to be able to have zones of different colours, I would need the axes v2
and v3
to be displayed on a logarithmic scale. Can you help me using this fake data set?
Upvotes: 0
Views: 470
Reputation: 263391
Still not sure what your problem might be (after fixing the mathematical nonsense.)
require(rgl)
data$lv3<- log(data$v3)
data$lv2<- log(data$v2)
with(data, plot3d( v1,lv2,lv3, col=c("red","blue")[1+VResponse]))
#after some rotation with the cursor:
rgl.snapshot("out.png")
Upvotes: 1