new plotting, omit_agent_obs

This commit is contained in:
steffen-illium
2021-06-02 18:12:56 +02:00
parent 8810955e86
commit b72013407e
5 changed files with 79 additions and 20 deletions

View File

@ -12,12 +12,11 @@ class MonitorCallback(BaseCallback):
ext = 'png'
def __init__(self, env, filepath=Path('debug_out/monitor.pick'), plotting=True):
def __init__(self, filepath=Path('debug_out/monitor.pick'), plotting=True):
super(MonitorCallback, self).__init__()
self.filepath = Path(filepath)
self._monitor_df = pd.DataFrame()
self._monitor_dict = dict()
self.env = env
self.plotting = plotting
self.started = False
self.closed = False

View File

@ -26,18 +26,19 @@ def plot(filepath, ext='png'):
plt.clf()
def prepare_plot(filepath, results_df, ext='png'):
results_df.Measurement = results_df.Measurement.str.replace('_', '-')
hue_order = sorted(list(results_df.Measurement.unique()))
def prepare_plot(filepath, results_df, ext='png', hue='Measurement', style=None):
df = results_df.copy()
df[hue] = df[hue].str.replace('_', '-')
hue_order = sorted(list(df[hue].unique()))
try:
sns.set(rc={'text.usetex': True}, style='whitegrid')
sns.lineplot(data=results_df, x='Episode', y='Score', hue='Measurement',
ci=95, palette=PALETTE, hue_order=hue_order)
sns.lineplot(data=df, x='Episode', y='Score', ci=95, palette=PALETTE,
hue_order=hue_order, hue=hue, style=style)
plot(filepath, ext=ext) # plot raises errors not lineplot!
except (FileNotFoundError, RuntimeError):
print('Struggling to plot Figure using LaTeX - going back to normal.')
plt.close('all')
sns.set(rc={'text.usetex': False}, style='whitegrid')
sns.lineplot(data=results_df, x='Episode', y='Score', hue='Measurement',
sns.lineplot(data=df, x='Episode', y='Score', hue=hue, style=style,
ci=95, palette=PALETTE, hue_order=hue_order)
plot(filepath, ext=ext)