#3.8
x <- seq(-2,3,0.05);y <- seq(-1,7,0.05)
f <- function(x,y){x^4-2*x^2*y+x^2-2*x*y+4.5*x-4*y+4}
z <- outer(x,y,f)
par(mfrow = c(1,2))
contour(x,y,z,levels= c(0:5,seq(5,20,5),seq(30,60,10),80,100))
persp(x,y,z,theta = 35,phi = 30,expand = 1,col = "blue")
三维画图需要生成z轴,即对x,y在z=f(x,y)的关系下做外积运算。利用rgl包可生成3d版本的persp图形
library('rgl')
persp3d(x,y,z,col = "blue")
#抓取合适的角度
view <- par3d("userMatrix")
转载于:https://www.cnblogs.com/Dearc/p/4310701.html
相关资源:垃圾分类数据集及代码