rewrite sample for plot