"""Fig 4b: per-theta viewpoint chart — Cameron's exact specs.

figsize=(6, 3.5), dpi=200, DejaVu Sans 11pt, solid+dashed, x ticks at each theta,
y 0-100, no grid, subtle axes, legend upper right.
"""
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt

plt.rcParams["font.family"] = "DejaVu Sans"
plt.rcParams["font.size"] = 11

theta = [0, 3.6, 7.1, 10.7, 14.3, 17.9, 21.4, 25]
para  = [88, 79, 62, 63, 62, 62, 33, 38]
act   = [67, 54, 42, 17, 12,  0,  0,  0]

PARA_COLOR = "#16653a"
ACT_COLOR  = "#a12029"

fig, ax = plt.subplots(figsize=(6, 3.5), dpi=200)

ax.plot(theta, para, color=PARA_COLOR, linewidth=2, marker="o", markersize=7,
        markerfacecolor=PARA_COLOR, markeredgecolor="white", markeredgewidth=1.2,
        label="PARA")
ax.plot(theta, act, color=ACT_COLOR, linewidth=2, marker="s", markersize=7,
        markerfacecolor=ACT_COLOR, markeredgecolor="white", markeredgewidth=1.2,
        linestyle="--", label="ACT")

ax.set_xlabel("Camera Elevation Angle θ (degrees)")
ax.set_ylabel("Success Rate (%)")
ax.set_xlim(-1, 26)
ax.set_ylim(0, 100)
ax.set_xticks(theta)
ax.set_yticks([0, 25, 50, 75, 100])
ax.spines["top"].set_visible(False)
ax.spines["right"].set_visible(False)
ax.spines["left"].set_color("#888888")
ax.spines["bottom"].set_color("#888888")
ax.tick_params(colors="#444444", labelsize=10)
ax.legend(loc="upper right", frameon=False, fontsize=11)

plt.tight_layout()
out_dir = "/data/cameron/para/paper/figs/generated"
plt.savefig(f"{out_dir}/fig4b_per_theta.png", format="png", bbox_inches="tight", dpi=200)
plt.savefig(f"{out_dir}/fig4b_per_theta.svg", format="svg", bbox_inches="tight")
print("Wrote fig4b_per_theta.png and fig4b_per_theta.svg")
