plotting within optimization iteration