Fixed a bug in the plotting script