Copy-pasted StackOverflow script.
Merging vis.py into dev to put it online at github.