finished code for plots