Lots of plotting refactoring for generalization.