Compare commits

..

3 Commits

Author SHA1 Message Date
478ac44825 fix: adjust title padding and save figure with additional padding in view_annotations 2026-07-14 15:26:18 -04:00
95ca9542e7 fix: display annotation frequency axis in MHz instead of raw Hz
Raw Hz values with the default scientific-notation formatter produced
a cluttered "1e9" axis offset. Format ticks in MHz via a FuncFormatter
instead, matching the other spectrogram views.
2026-07-14 15:16:28 -04:00
fbc19df6fb fix: correct annotation frequency label and tertiary annotation color
freq_lower_edge/freq_upper_edge are plain Hz values (no unit
conversion happens before plotting), so the axis was mislabeled
"Frequency (MHz)". Also lighten the palette's tertiary color, which
was nearly indistinguishable from the primary blue in the legend.
2026-07-14 14:31:11 -04:00

View File

@ -64,7 +64,7 @@ def view_annotations(
annotations = recording.annotations annotations = recording.annotations
# 2. Setup Color Mapping # 2. Setup Color Mapping
palette = ["#2196F3", "#9C27B0", "#64B5F6", "#7B1FA2", "#5C6BC0", "#CE93D8", "#1565C0", "#7C4DFF"] palette = ["#2196F3", "#9C27B0", "#EAF4FE", "#7B1FA2", "#5C6BC0", "#CE93D8", "#1565C0", "#7C4DFF"]
unique_labels = sorted(list(set(ann.label for ann in annotations if ann.label))) unique_labels = sorted(list(set(ann.label for ann in annotations if ann.label)))
label_to_color = {label: palette[i % len(palette)] for i, label in enumerate(unique_labels)} label_to_color = {label: palette[i % len(palette)] for i, label in enumerate(unique_labels)}
@ -102,13 +102,14 @@ def view_annotations(
] ]
ax.legend(handles=legend_elements, loc="upper right", framealpha=0.2) ax.legend(handles=legend_elements, loc="upper right", framealpha=0.2)
ax.set_title(title, fontsize=title_fontsize, pad=20) ax.set_title(title, fontsize=title_fontsize, pad=14)
ax.set_xlabel("Time (s)", fontsize=12) ax.set_xlabel("Time (s)", fontsize=12)
ax.set_ylabel("Frequency (MHz)", fontsize=12) ax.set_ylabel("Frequency (MHz)", fontsize=12)
ax.yaxis.set_major_formatter(ticker.FuncFormatter(lambda y, _: f"{y / 1e6:.1f}"))
ax.grid(alpha=0.1) ax.grid(alpha=0.1)
output_path, _ = set_path(output_path=output_path) output_path, _ = set_path(output_path=output_path)
plt.savefig(output_path, dpi=dpi, bbox_inches="tight") plt.savefig(output_path, dpi=dpi, bbox_inches="tight", pad_inches=0.2)
plt.close(fig) plt.close(fig)
print(f"Professional annotation plot saved to {output_path}") print(f"Professional annotation plot saved to {output_path}")