add legend as suggested by @ramnath
fix all examples to use d1$legend instead of d1$set(legend=