some fancy scipy stuff with graphs from tutorial