-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path3D plots that POP!
More file actions
27 lines (17 loc) · 1013 Bytes
/
3D plots that POP!
File metadata and controls
27 lines (17 loc) · 1013 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#Produce 3D anaglyphs in R using the 'anaglyph' package
library(anaglyph)
library(vegan)
species<-data(varespec) #example data from vegan package
NMDS<-metaMDS(varespec, k=3) #where k equal the number of dimensions
sites <- scores(NMDS, display = "sites") #run NMDS
x<-sites[,1] #assign each dimension or axis to an object
y<-sites[,2]
z<-sites[,3]
anaglyph.plot(x, y, z, left = "red", right = "cyan", depth = "med", style = "pop-out", pch=20, xlab="Axis 1", ylab="Axis 2")
#Produce a 3D plot using 'ordiplot3d' function
ordination<-ordiplot3d(NMDS, display = "sites", choices = 1:3, xlab="Axis 1", ylab="Axis 2", zlab="Axis 3", type="n") #make cyan 3D ordination
points(ordination, "points", pch=20, col="cyan")
dev.copy2eps() #save as .eps and rename "cyan"
ordination<-ordiplot3d(NMDS, display = "sites", choices = 1:3, xlab="Axis 1", ylab="Axis 2", zlab="Axis3", type="n")#make cyan 3D ordination
points(ordination, "points", pch=20, col="red")
dev.copy2eps() #save as .eps and rename "red"