EDIT: Added graphing code