Skip to content

Instantly share code, notes, and snippets.

@thomasweng15
Created January 23, 2020 20:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thomasweng15/ec5fde936ac5381fa8c745243a3ab27a to your computer and use it in GitHub Desktop.
Save thomasweng15/ec5fde936ac5381fa8c745243a3ab27a to your computer and use it in GitHub Desktop.
Plots for peg insertion project
import seaborn as sns; sns.set()
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
def plot(run_IDs, run_labels, factors, titles,
colors=['steelblue', 'orange', 'mediumseagreen', 'red', 'purple'],
ecolors=['lightblue', 'navajowhite', 'lightgreen', 'pink', 'plum'],
dpi=150):
csv_names = ['run_%d/progress.csv' % i for i in run_IDs]
dfs = [pd.read_csv(f) for f in csv_names]
for f_idx, factor in enumerate(factors):
factor_dfdata = []
for i, df in enumerate(dfs):
dfdict = {
'iter': df['Iteration'],
'avg': df['%sAverage' % factor],
'std': df['%sStd' % factor]
}
factor_dfdata.append((i, dfdict))
plt.figure(dpi=dpi)
plt.title(titles[f_idx])
plt.legend()
for j, data in factor_dfdata:
ax = sns.lineplot(x=data['iter'], y=data['avg'], label=run_labels[j], color=colors[j])
# Clip error for length factor
yerr_upper = data['avg']+data['std']
if factor == 'Length':
yerr_upper = yerr_upper.clip(upper=2000)
ax.fill_between(data['iter'], data['avg']-data['std'], yerr_upper, color=ecolors[j], alpha=0.8)
plt.tight_layout()
plot([37, 38], ['1 F/T reading', '8 F/T readings'], ['DiscountedReturn'], ['Avg. Discounted Return with varying num. of F/T readings, 0.03 noise'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment