[This article was first published on mages' blog, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Michael Bach, who is a professor and vision scientist at the University of Freiburg, maintains a fascinating site about visual illusions. One visual illusion really surprised me: the sigma motion.

The sigma motion displays a flickering figure of black and white columns. Actually it is just a chart, as displayed below, with the columns changing backwards and forwards from black to white at a rate of about 30 transitions per second.

It can be a bit irritating to watch the movement, hence I use a button here to display and hide the animation.

Now, put your finger on the animated chart and move the finger to the left or right, so that you cover the chart in about 2 seconds and you will notice that the flickering stops and instead it appears that the columns move in the same direction as your finger! It works particular well on a touch screen device.

You find more information, details and another implementation on Michael’s page. Below is the little R script which produced the charts/GIFs used in this post.

### R code to replicate plots

```library(animation) fps <- 30 nstripes <- 20 ani.options(interval=1/fps, ani.width=600, ani.height=100) sm <- function(n=20, col=c("black", "white")){ x <- c(1:(2*n)) y <- 1 z <- matrix(rep(c(1,0),n), ncol=1) image(x, y, z, col=col, bty="n", xaxt="n", yaxt="n", xlab="", ylab="") } saveMovie({ op <- par(mar=c(0,0,0,0)) for(i in c(1:(2*fps))){ sm(nstripes, col=c("black","white")) sm(nstripes, col=c("white","black")) } par(op) }) ## You will find the output here: file.path(tempdir(), "animation.gif") sessionInfo() ## R version 2.15.1 (2012-06-22) ## Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit) ## ## locale: ## [1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8 ## ## attached base packages: ## [1] stats graphics grDevices utils datasets methods base ## ## other attached packages: ## [1] animation_2.1 ```

To leave a comment for the author, please follow the link and comment on their blog: mages' blog.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

# Never miss an update! Subscribe to R-bloggers to receive e-mails with the latest R posts.(You will not see this message again.)

Click here to close (This popup will not appear again)