| import matplotlib.pyplot as plt | |
| def show_grid(grid, title=None, cmap='tab10', vmin=0, vmax=9): | |
| plt.figure(figsize=(3, 3)) | |
| plt.imshow(grid, cmap=cmap, vmin=vmin, vmax=vmax) | |
| plt.colorbar(fraction=0.046, pad=0.04) | |
| if title: | |
| plt.title(title) | |
| plt.axis('off') | |
| plt.show() | |
| def show_side_by_side(grids, titles, cmap='tab10', vmin=0, vmax=9): | |
| n = len(grids) | |
| plt.figure(figsize=(3 * n, 3)) | |
| for i, (g, t) in enumerate(zip(grids, titles)): | |
| plt.subplot(1, n, i + 1) | |
| plt.imshow(g, cmap=cmap, vmin=vmin, vmax=vmax) | |
| plt.title(t) | |
| plt.axis('off') | |
| plt.tight_layout() | |
| plt.show() | |
| def plot_sigma_trace(sigmas, title="σ trace"): | |
| plt.figure(figsize=(4, 3)) | |
| plt.plot(range(len(sigmas)), sigmas, marker='o') | |
| plt.xlabel("Step") | |
| plt.ylabel("σ (L1 residue)") | |
| plt.title(title) | |
| plt.grid(True, alpha=0.3) | |
| plt.show() | |