xeval=seq(1,3,length=25) yeval=seq(1,2,length=25) #create a grid of 25 x 25 = 625 values in a two column matrix #basically each value of xeval is paired with all values of yeval to #develop the grid. xy=matrix(0,ncol=2,nrow=625) ij=0 for(i in 1:25){ for(j in 1:25){ ij=ij+1 xy[ij,1]=xeval[i] xy[ij,2]=yeval[j] } } #now estiimate the joint pdf at the above grid. > fxy=((3*xy[,1])-xy[,2])/9 #since the joint pdf is estimated on a regular grid #you can use the contour command directly contour(xeval, yeval, t(matrix(fxy), nrow=length(xeval), ncol=length(yeval)) #or persp(xeval, yeval, t(matrix(fxy), nrow=length(xeval), ncol=length(yeval)) #to get a perspective plot. library(akima) #assuming that you have the function 'akima' #pull down packages from the menu and select 'load packages' and follow #instructions. zz=interp(xy[,1],xy[,2],fxy) contour(zz) persp(zz) #To get a perspective plot..