Created
March 3, 2015 03:03
-
-
Save captainpete/c241e6e1f6729a638805 to your computer and use it in GitHub Desktop.
Extracted from http://cran.r-project.org/web/packages/anaglyph/index.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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