adds legend to graphs