-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathplot_density.py
57 lines (43 loc) · 1.49 KB
/
plot_density.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# Author: Arnaud Joly
import os
import operator
import numpy as np
import pandas as pd
import prettyplotlib as ppl
import matplotlib.pyplot as plt
dataframe = pd.read_csv("density.csv")
mean_chrono = dataframe.groupby("density").mean()
std_chrono = dataframe.groupby("density").std()
plt.figure()
for label in ["sparse", "dense"]:
plt.errorbar(mean_chrono.index, mean_chrono[label], std_chrono[label],
label=label)
ax = plt.gca()
for loc, spine in ax.spines.items():
if loc in ['left','bottom']:
spine.set_position(('outward', 10)) # outward by 10 points
# spine.set_smart_bounds(True)
elif loc in ['right','top']:
# spine.set_visible(False)
spine.set_color('none') # don't draw spine
else:
raise ValueError('unknown spine location: %s'%loc)
ax.set_xlim(0., 0.51)
ax.yaxis.set_ticks_position('left')
ax.xaxis.set_ticks_position('bottom')
ax.set_xlabel("Input space density")
ax.set_ylabel("Time [s]")
# ax.xaxis.set_major_locator(MaxNLocator(6, prune=None))
# ax.yaxis.set_major_locator(MaxNLocator(6, prune=None))
# Sort legend labels
handles, labels = ax.get_legend_handles_labels()
hl = sorted(zip(handles, labels), key=operator.itemgetter(1))
if hl:
handles2, labels2 = zip(*hl)
legend = ax.legend(handles2, labels2, loc="best")
legend.get_frame().set_alpha(0.5)
legend.get_frame().set_edgecolor('white')
plt.tight_layout()
if not os.path.exists("images"):
os.makedirs("images")
plt.savefig("images/density.pdf")