Improved plotting script