2 from __future__ 
import print_function
 
    4 import matplotlib.pyplot 
as plt
 
    9 from itertools 
import chain
 
   13 parser = argparse.ArgumentParser(description=
"Plot benchmark result csv")
 
   14 parser.add_argument(
"csv_file", help=
"csv file")
 
   15 parser.add_argument(
"--image-suffix", default=
"eps", help=
"suffix to save image")
 
   16 parser.add_argument(
"--only-save-image", action=
"store_true", help=
"die right after saving image")
 
   17 parser.add_argument(
"--min", default=0, type=float, help=
"minimum value")
 
   18 parser.add_argument(
"--max", default=0.2, type=float, help=
"maximum value")
 
   19 args = parser.parse_args()
 
   20 csv_file = args.csv_file
 
   25 def plot(theta, one_data, ax):
 
   27     xs = [data[0] 
for data 
in one_data]
 
   28     ys = [data[1] 
for data 
in one_data]
 
   30     for x, y, i 
in zip(xs, ys, range(len(xs))):
 
   31         zs[(x, y)] = one_data[i][2]
 
   38     img = np.arange(0, len(xs) * len(ys), 1.0).reshape((len(xs), len(ys)))
 
   39     for x, i 
in zip(xs, range(len(xs))):
 
   40         for y, j 
in zip(ys, range(len(ys))):
 
   44                 print(
"Failed to find (%f, %f)" % (x, y), file=sys.stderr)
 
   47     im = ax.imshow(img, vmin=minz, vmax=maxz, cmap=
"gnuplot")
 
   48     ax.set_xticklabels(np.arange(-dx - 1, dx+1))
 
   49     ax.set_yticklabels(np.arange(-dy - 1, dy+1))
 
   50     ax.set_xlabel(
"$x$ [m]")
 
   51     ax.set_ylabel(
"$y$ [m]")
 
   52     ax.set_title(
'$\\theta = %.0f$ deg' % (theta / pi * 180.0))
 
   55 reader = csv.reader(open(csv_file))
 
   56 fields = reader.next()
 
   66         figure_num = int(row[fields.index(
"n_theta")])
 
   67         if figure_num % 3 == 0:
 
   70             xnum = figure_num / 3 + 1
 
   71         fig, axes = plt.subplots(xnum, 3)
 
   73     theta_str = row[fields.index(
"theta")]
 
   75     if theta_str 
not in data:
 
   77     data[theta_str].append((
float(row[fields.index(
"x")]), 
float(row[fields.index(
"y")]), 
float(row[fields.index(
"one_time")])))
 
   81 for theta 
in sorted(data.keys()):
 
   82     one_data = data[theta]
 
   83     print(
"Plotting theta=", theta)
 
   84     plot(
float(theta), one_data, axes.flat[counter])
 
   87 for a 
in axes.flat[counter:]:
 
   90 fig.subplots_adjust(right = 0.8)
 
   91 cbar_ax = fig.add_axes([0.85, 0.15, 0.05, 0.7])
 
   92 cb = fig.colorbar(im, cax=cbar_ax)
 
   93 cb.set_label(
"Time [sec]")
 
   97 eps_file = os.path.basename(csv_file) + 
"." + args.image_suffix
 
   98 print(
"Saving to %s file: " % (args.image_suffix), eps_file)
 
  100 if args.only_save_image: