[R] help with 3-D plot of kernel density estimates

Duncan Murdoch murdoch at stats.uwo.ca
Tue Mar 17 12:13:47 CET 2009


On 17/03/2009 6:44 AM, Josh wrote:
> Hi,
> I guess I have a naive question. I use kde2d function in a standard way to
> estimate kernel densities of x and y (x and y are vectors) and plot them
> using image().
> 
> f1=kde2d(x,y)
> image(f1)
> 
> But what if I want to see kernel estimates of three variables, x, y and z (a
> vector) plotted together ? Something in which x<->y is plotted and colored
> according to the corresponding value of z ?


See the kde3d example in the misc3d package for contour plots of a 3d 
density function (not as you described, but very nicely done).

Or if you just want 3d plots of a 2d function, you can use persp (from 
graphics) or persp3d (from rgl).

Duncan Murdoch




More information about the R-help mailing list