4d plot in R (how to color points in space)

64 Views Asked by At

I would like to create 3d plot for x,y,z (cordinates) and values expressed as a color, calculated from a function conc1. I tried with this code:

#declaration of some parameters of function "conc1"
Q<-1
t<-0
sx<-sy<-sz<-1
#coordinates of points
x<-seq(-3,3,length=100)
y<-seq(-3,3, length=100)
z<-seq(-3,3,length=100)
#function
conc1<-function(x,y,z){(Q/(sqrt(8*pi^3)*sx*sy*sz))*exp(-((x-u*t)^2/2*sx^2)-(y^2/2*sy^2)-(z^2/2*sz^2))}
#ploting a function conc1
scatter3D(x, y, z, colvar = conc1, ...)
#

I got an error: Error in scatter3D(x, y, z, colvar = conc1, pch = 19, cex = 0.5) : 'colvar' should have same length as 'x', 'y' and 'z' In addition: Warning message: In is.na(var) : is.na() applied to non-(list or vector) of type 'closure'

I would be grateful if you could help me with that problem?

0

There are 0 best solutions below