Calculate average, plot graphs