figure plot refactoring