plot refactoring