Skip to content

Instantly share code, notes, and snippets.

@wactbprot
Last active August 28, 2020 19:37
Show Gist options
  • Save wactbprot/3736638 to your computer and use it in GitHub Desktop.
Save wactbprot/3736638 to your computer and use it in GitHub Desktop.
R and colors from another dimension
n <- 200
np <- n*pi
x <- 1:n
y <- cos(x/np)
z <- sin(x/np)
zp <- z - min(z)
zpp <- zp/max(zp)
cf <- colorRampPalette(c("blue","yellow","red"))
plot(x,y,col=cf(n)[n*zpp])
grid(col="black")
@wactbprot
Copy link
Author

n is missing here! It is

 n <- length(x)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment