Refactor: Move plot drawing to lib.R