# Surface Example # R script to create perspective and contour plots. f = function(x, y) { return(13 + 2*x + 3*y - 2.5*x^2 - 3.5*y^2 + 2*x*y) } f(2, 3) x = seq(-1, 1, 0.1) y = seq(-1, 1, 0.1) z = outer(x, y, f) pdf("contour-plots.pdf") persp(x, y, z, theta=30, phi=30, xlab="x", ylab="y", zlab="z", main="3 Dimensional Perspective Plot") contour(x, y, z, nlevels=10, xlab="x", ylab="y", main="Contour Plot") dev.off( )