plot data file and compute cost