Skip to content

Commit 4f94cbe

Browse files
committed
Update plot
1 parent b9437d0 commit 4f94cbe

2 files changed

Lines changed: 12 additions & 12 deletions

File tree

-9.8 KB
Loading

experiments/alaro/trap_bandit/run.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -421,17 +421,17 @@ def plot_risky_condition_grid(
421421
conditions: list[str],
422422
agents: list[str],
423423
) -> None:
424-
fig, axes = plt.subplots(len(conditions), 2, figsize=(9, 6), sharex=True)
424+
fig, axes = plt.subplots(2, len(conditions), figsize=(9, 6), sharex=True)
425425
if len(conditions) == 1:
426-
axes = np.asarray([axes])
426+
axes = np.asarray(axes).reshape(2, 1)
427427

428-
for row, condition in enumerate(conditions):
428+
for col, condition in enumerate(conditions):
429429
summary = load_summary(results_dir, condition)
430-
ax_regret = axes[row, 0]
431-
ax_trapped = axes[row, 1]
430+
ax_regret = axes[0, col]
431+
ax_trapped = axes[1, col]
432432

433433
for agent in agents:
434-
group = summary[agent]["risky"]
434+
group = summary[agent]["all"]
435435
p5, p50, p95 = np.asarray(group["regret_p5_p50_p95"])
436436
steps = np.arange(len(p50))
437437
label = AGENT_LABELS.get(agent, agent)
@@ -456,14 +456,14 @@ def plot_risky_condition_grid(
456456
)
457457
ax_trapped.fill_between(steps, p5, p95, alpha=0.12, color=color)
458458

459-
ax_regret.set_ylabel(CONDITION_LABELS.get(condition, condition))
460-
ax_regret.set_title("Cumulative expected regret" if row == 0 else "")
461-
ax_trapped.set_title("Risky arm pull rate" if row == 0 else "")
459+
ax_regret.set_title(CONDITION_LABELS.get(condition, condition))
462460
ax_trapped.set_ylim(-0.02, 1.02)
463461

464-
axes[-1, 0].set_xlabel("step")
465-
axes[-1, 1].set_xlabel("step")
466-
axes[0, 1].legend(loc="upper right", fontsize=8)
462+
axes[0, 0].set_ylabel("Cumulative expected regret")
463+
axes[1, 0].set_ylabel("Risky arm pull rate")
464+
for ax in axes[-1, :]:
465+
ax.set_xlabel("step")
466+
axes[0, -1].legend(loc="upper right", fontsize=8)
467467
fig.tight_layout()
468468
fig.savefig(output_path, dpi=160)
469469
plt.close(fig)

0 commit comments

Comments
 (0)