Refactored plotting into class