Skip to content

Instantly share code, notes, and snippets.

@leeper
Created November 4, 2013 18:13
Show Gist options
  • Save leeper/7306869 to your computer and use it in GitHub Desktop.
Save leeper/7306869 to your computer and use it in GitHub Desktop.
Test of drop shadows on white and black backdrops
# Drop shadows
# some data
x <- cbind(c(2,3,3,4,5,3,2),
c(3,3,5,4,3,2,1),
c(1,2,1,2,2,3,6))
# Dark backdrop
# set plot background to black
par(bg='black', col.axis='white', col.lab='white',
col.main='white', col.sub='white')
# plot
plot(NA, type='b', xlim=c(1,7), ylim=c(0,6), xlab='Time', ylab='Value', las=1)
lines(x=1:7, y=x[,1]-.01, type='l', col='gray', lwd=2) # drop shadow
lines(x=1:7, y=x[,1], type='l', col='red', lwd=2)
lines(x=1:7, y=x[,2]-.01, type='l', col='gray', lwd=2) # drop shadow
lines(x=1:7, y=x[,2], type='l', col='blue', lwd=2)
lines(x=1:7, y=x[,3]-.01, type='l', col='gray', lwd=2) # drop shadow
lines(x=1:7, y=x[,3], type='l', col='green', lwd=2)
# reset to standard backdrop
par(bg='white', col.axis='black', col.lab='black',
col.main='black', col.sub='black')
plot(NA, type='b', xlim=c(1,7), ylim=c(0,6), xlab='Time', ylab='Value', las=1)
lines(x=1:7, y=x[,1]-.01, type='l', col='black', lwd=2) # drop shadow
lines(x=1:7, y=x[,1], type='l', col='red', lwd=2)
lines(x=1:7, y=x[,2]-.01, type='l', col='black', lwd=2) # drop shadow
lines(x=1:7, y=x[,2], type='l', col='blue', lwd=2)
lines(x=1:7, y=x[,3]-.01, type='l', col='black', lwd=2) # drop shadow
lines(x=1:7, y=x[,3], type='l', col='green', lwd=2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment