a code taken from http://jakevdp.github.io/blog/2012/08/18/matplotlib-animation-tutorial/ to make animations