I need to plot a trivariate function that corresponds three variables i.e the variables (x,y,z) and the function f(x,y,z). How I can visualise them I want to plot all possible slices of the three variables
and present each value of f(x,y,z) on each cell this is a sample of my results.
X , Y , Z , f(x,y,z)
0 , 0 , 0 , 0.7186750606557863
0 , 0 , 1 , 0.1816545219749217
0 , 0 , 2 , 0.1325766227290934
0 , 0 , 3 , 0.148513111388832
0 , 0 , 4 , 0.1215885009152961
0 , 0 , 5 , 0.2159501472892012
0 , 0 , 6 , 0.04605873415965471
0 , 0 , 7 , 0.1356269218857206
0 , 0 , 8 , 0.257822547019855
0 , 0 , 9 , 0.1914359947246274
0 , 0 , 10 , 0.2325336254052311
0 , 0 , 11 , 0.2053227931342235
0 , 0 , 12 , 0.2090946039028279
0 , 0 , 13 , 0.3491765529107006
0 , 0 , 14 , 0.1214783354308278
0 , 0 , 15 , 0.1715156020994479
0 , 0 , 16 , 0.3727796332918811
0 , 0 , 17 , 0.3290024642878383
0 , 0 , 18 , 0.1980557215900901
0 , 0 , 19 , 0.6611507752039599
when I was searcging I found a package called plot3D, it require to define each variable and a define a variable colvar that take the variables with the corresponding function f(x,y,z) as bellow. Then plot the slice.
x <- X[,1]
y <- X[,2]
z <- X[,3]
grid <- mesh(x, y, z)
colvar <- with(grid, X[,4])
# default is just the panels
slice3D(x, y, z, colvar = colvar, theta = 60)
when I run it, give the error below
>Error in addslice(NULL, x, y, z, colvar, xs = xs, ys = ys, zs = zs, plist = plist, :
'colvar' has to be an array of dimension 3
I didnt know how to solve the issue, also I need it to plot several slices not one.
Can someone help how to plot this type of data using R?
Haz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.