-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathplot_stats.py
More file actions
40 lines (33 loc) · 1.34 KB
/
Copy pathplot_stats.py
File metadata and controls
40 lines (33 loc) · 1.34 KB
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
import pickle
import numpy as np
import matplotlib.pyplot as plt
import statistics
class Stats:
def __init__(self, file):
with open (file, 'rb') as fp:
stats = pickle.load(fp)
self.mean = stats[2]
self.noisy_mean = stats[4]
self.std = stats[3]
self.samples = stats[1]
self.low = []
self.high = []
for i in range(len(self.mean)):
self.low.append(self.mean[i]-self.std[i])
self.high.append(self.mean[i]+self.std[i])
#self.samples.append(i)
def plot(self, ax, color='g', variance_color='lightgreen', label=''):
ax.plot(self.noisy_mean, color, label=label)
#ax.fill_between(self.samples, self.low, self.high, alpha=1, color=variance_color)
stats_walker_no_contact_1 = Stats("stats/walker2d_no_contact_seed8_Iter201.stat")
stats_walker_contact_1 = Stats("stats/walker2d_contact_seed8_Iter201.stat")
stats_walker_contact_2 = Stats("stats/walker2d_contact_seed16_Iter201.stat")
fig = plt.figure()
ax = fig.add_subplot(111)
stats_walker_no_contact_1.plot(ax, color='r', label='Walker_Non_Partition', variance_color='salmon')
stats_walker_contact_1.plot(ax, color='g', label='Walker_Partition', variance_color='lightgreen')
stats_walker_contact_2.plot(ax, color='g', label='Walker_Partition', variance_color='lightgreen')
plt.ticklabel_format(style='sci', axis='x', scilimits=(0,0))
ax.set_xlim([0,201])
plt.legend(loc='upper left')
plt.show()