您好,欢迎访问三七文档
16.1library(rgl)tetra-function(){t1-tetrahedron3d()t2vb-t1$vbt2vb[1,]--3t2-tmesh3d(t2vb,t1$it)plane-qmesh3d(rbind(rep(-3.01,4),c(-2,-2,2,2),c(-3,3,3,-3),rep(1,4)),matrix(1:4,ncol=1))open3d(windowRect=c(0,0,600,600))#clear3d()shade3d(plane,color=white,specular=black)wire3d(plane)wire3d(t1,lwd=3)wire3d(t2,lwd=3)segments3d(rbind(t2$vb[1,t2$it],t1$vb[1,t1$it]),rbind(t2$vb[2,t2$it],t1$vb[2,t1$it]),rbind(t2$vb[3,t2$it],t1$vb[3,t1$it]),col=gray,lwd=3)view3d(40,-30)}t1-cube3d()t1tube-t1t1tube$ib-t1tube$ib[,-(3:4)]t2vb-t1$vbt2vb[1,]--5t2-qmesh3d(t2vb,t1$ib)plane-qmesh3d(rbind(rep(-5.01,4),c(-2,-2,2,2),c(-3,3,3,-3),rep(1,4)),matrix(1:4,ncol=1))open3d(windowRect=c(0,0,600,600))#clear3d()shade3d(plane,color=white,ambient=white,specular=white,emission=white)wire3d(plane)shade3d(t1tube,color=white,specular=black)wire3d(t1,lwd=3)wire3d(t2,lwd=3)segments3d(rbind(t2$vb[1,t2$ib[,4]],t1$vb[1,t1$ib[,4]]),rbind(t2$vb[2,t2$ib[,4]],t1$vb[2,t1$ib[,4]]),rbind(t2$vb[3,t2$ib[,4]],t1$vb[3,t1$ib[,4]]),col=gray,lwd=3)view3d(55,-20,fov=0)rgl.postscript(Figures/threed-3dproj.eps)system(epstopdfFigures/threed-3dproj.eps)system(convertFigures/threed-3dproj.pdfWeb/threed-3dproj.png)16.2library(rgl)tetra-function(){t2vb-t1$vbt2vb[1,]--3t2vb[2,c(1,4)]-t2vb[2,c(1,4)]*.8t2vb[3,c(1,4)]-t2vb[3,c(1,4)]*.8t2vb[2,2:3]-t2vb[2,2:3]*.6t2vb[3,2:3]-t2vb[3,2:3]*.6t2-tmesh3d(t2vb,t1$it)t3vb-t1$vbt3vb[1,]--10t3vb[2,]-0t3vb[3,]-0t3-tmesh3d(t3vb,t1$it)open3d(windowRect=c(0,0,600,600))#clear3d()shade3d(plane,color=white,specular=black)wire3d(plane)wire3d(t1,lwd=3)wire3d(t2,lwd=3)segments3d(rbind(t3$vb[1,t3$it],t1$vb[1,t1$it]),rbind(t3$vb[2,t3$it],t1$vb[2,t1$it]),rbind(t3$vb[3,t3$it],t1$vb[3,t1$it]),col=gray,lwd=3)shade3d(translate3d(scale3d(cube3d(),.1,.1,.1),-10,0,0))view3d(50,-20,zoom=.8)}t1-cube3d()t1tube-t1t1tube$ib-t1tube$ib[,-(3:4)]t2vb-t1$vbt2vb[2,t1$ib[,4]]-t2vb[2,t1$ib[,4]]*.4t2vb[3,t1$ib[,4]]-t2vb[3,t1$ib[,4]]*.4t2vb[2,t1$ib[,3]]-t2vb[2,t1$ib[,3]]*.6t2vb[3,t1$ib[,3]]-t2vb[3,t1$ib[,3]]*.6t2vb[1,]--4.5t2-qmesh3d(t2vb,t1$ib)t2tube-t2t2tube$ib-t2tube$ib[,-(3:4)]t3-translate3d(scale3d(cube3d(),.1,.1,.1),-10,0,0)plane-qmesh3d(rbind(rep(-4.51,4),c(-2,-2,2,2),c(-3,3,3,-3),rep(1,4)),matrix(1:4,ncol=1))open3d(windowRect=c(0,0,600,300))#clear3d()shade3d(plane,color=white,ambient=white,specular=white,emission=white)wire3d(plane)shade3d(t1tube,color=white,specular=black)wire3d(t1,lwd=3)shade3d(t2tube,color=white,specular=black)wire3d(t2,lwd=3)segments3d(rbind(-10,t1$vb[1,t1$ib[,4]]),rbind(0,t1$vb[2,t1$ib[,4]]),rbind(0,t1$vb[3,t1$ib[,4]]),col=gray,lwd=3)shade3d(t3)view3d(50,-15,fov=0,zoom=.7)rgl.postscript(Figures/threed-3dvp.eps)system(epstopdfFigures/threed-3dvp.eps)system(convertFigures/threed-3dvp.pdfWeb/threed-3dvp.png)16.3quakes-read.csv(Quake/earthquakes.csv)NZquakes-quakes[c(LAT,LONG,MAG,DEPTH)]cantyQuakes-quakes[quakes$LAT-42.4&quakes$LAT-44&quakes$LONG171&quakes$LONG173.5,]library(MASS)quakeDens-kde2d(cantyQuakes$LONG,cantyQuakes$LAT,n=30)par(mar=rep(0,4))persp(quakeDens)16.4quakes-read.csv(Quake/earthquakes.csv)NZquakes-quakes[c(LAT,LONG,MAG,DEPTH)]cantyQuakes-quakes[quakes$LAT-42.4&quakes$LAT-44&quakes$LONG171&quakes$LONG173.5,]library(MASS)quakeDens-kde2d(cantyQuakes$LONG,cantyQuakes$LAT,n=30)par(mar=rep(0,4))persp(quakeDens,scale=FALSE,expand=0.02,theta=60,d=.1,r=.1,xlab=longitude,ylab=latitude,zlab=)16.5quakes-read.csv(Quake/earthquakes.csv)NZquakes-quakes[c(LAT,LONG,MAG,DEPTH)]cantyQuakes-quakes[quakes$LAT-42.4&quakes$LAT-44&quakes$LONG171&quakes$LONG173.5,]library(MASS)quakeDens-kde2d(cantyQuakes$LONG,cantyQuakes$LAT,n=30)par(mar=rep(0,4))zinterp-with(quakeDens,z[-1,-1]+z[-1,-ncol(z)]+z[-nrow(z),-1]+z[-nrow(z),-ncol(z)])persp(quakeDens,scale=FALSE,expand=0.02,theta=60,d=.1,r=.1,axes=FALSE,box=FALSE,col=gray(.4+1:6/10)[cut(zinterp,6)])16.6quakes-read.csv(Quake/earthquakes.csv)NZquakes-quakes[c(LAT,LONG,MAG,DEPTH)]cantyQuakes-quakes[quakes$LAT-42.4&quakes$LAT-44&quakes$LONG171&quakes$LONG173.5,]library(MASS)quakeDens-kde2d(cantyQuakes$LONG,cantyQuakes$LAT,n=30)shallowCantyQuakes-subset(cantyQuakes,DEPTH20)trellis.device(pdf,color=FALSE,file=Figures/threed-cloud%d.pdf,onefile=FALSE)for(iinseq(40,80,20)){print(cloud(-DEPTH~LONG+LAT,shallowCantyQuakes,xlim=c(171,173),ylim=c(-44.5,-42.5),pch=16,col=rgb(0,0,0,.5),screen=list(z=i,x=-70)))}dev.off()16.7quakes-read.csv(Quake/earthquakes.csv)NZquakes-quakes[c(LAT,LONG,MAG,DEPTH)]cantyQuakes-quakes[quakes$LAT-42.4&quakes$LAT-44&quakes$LONG171&quakes$LONG173.5,]library(MASS)quakeDens-kde2d(cantyQuakes$LONG,cantyQuakes$LAT,n=30)shallowCantyQuakes-subset(cantyQuakes,DEPTH20)library(scatterplot3d)par(lab=c(3,3,0))s3d-with(shallowCantyQuakes,scatterplot3d(-DEPTH~LONG+LAT,angle=30,scale.y=0.45,type=n,pch=16,color=rgb(0,0,0,.5),x.ticklabs=pretty(LONG,3),grid=FALSE,zlim=c(-20,0)))quakeDensXY-kde2d(shallowCantyQuakes$LONG,shallowCantyQuakes$LAT,n=30)lapply(contourLines(quakeDensXY,nlevels=8),function(cl){polygon(s3d$xyz.convert(cl$x,
本文标题:R绘图系统16
链接地址:https://www.777doc.com/doc-2856336 .html