Work in Progress
Flake8 now gives zero comments.
WIP

made the figure bigger.
Extracted some functionality into functions.