-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathplotResults.py
More file actions
27 lines (24 loc) · 1.11 KB
/
plotResults.py
File metadata and controls
27 lines (24 loc) · 1.11 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
from baselines.common import plot_util as pu
import matplotlib.pyplot as plt
import argparse
import os
"""Create a plot of training data for a given environment using baselines plotting utility
Command line arguments:
--env: environment name (ex: --env=RoboschoolHalfCheetah-v1)
--dir: directory where training data is logged default is ./data/
"""
if __name__ == "__main__":
# Parse command line arguments
parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('--env', help='Environment name')
parser.add_argument('--dir', help='Data directory', default='./data')
args = parser.parse_args()
envName = args.env
# Load results with baselines plot utility
results = pu.load_results('./'+args.dir+'/'+envName)
# Plot results
pu.plot_results(results, average_group=True, split_fn=lambda _: '', shaded_std=False)
# Save plot as a pdf in a subdirectory of the data directory called plots
if not os.path.exists('./'+args.dir+'/plots'):
os.mkdir('./'+args.dir+'/plots')
plt.savefig('./'+args.dir+'/plots/'+envName+'.pdf')