working code, producing 4 plots