Skip to content

Instantly share code, notes, and snippets.

@captainpete
Created March 3, 2015 03:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save captainpete/c241e6e1f6729a638805 to your computer and use it in GitHub Desktop.
Save captainpete/c241e6e1f6729a638805 to your computer and use it in GitHub Desktop.
anaglyph.plot <- function(x,y,z,left="red",right="cyan",depth="med",style="pop-out",type="p",...) {
if (depth=="low") {
scale <- 0.1
} else if (depth=="med") {
scale <- 0.2
} else if (depth=="high") {
scale <- 0.5
}
if (style=="pop-in") {
shift <- 1
} else if (style=="none") {
shift <- 0.5
} else if (style=="pop-out") {
shift <- 0
}
# convert z-values to adjustment (between 0 and 1)
adjust <- ((z - min(z))/(max(z)-min(z))-shift)*scale
xy1 <- xy.coords(x+adjust/2,y)
xy2 <- xy.coords(x-adjust/2,y)
plot(xy1, col=right,...)
plot.xy(xy2, col=left, type=type,...)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment