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