From 85092e846b8dfccec0c4f056e35047c75c90d864 Mon Sep 17 00:00:00 2001 From: Santiago Martinez Date: Fri, 7 Apr 2023 15:46:04 -0600 Subject: [PATCH] Better frequency axis tick values --- batdetect2/plot.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/batdetect2/plot.py b/batdetect2/plot.py index fdd4963..e08308a 100644 --- a/batdetect2/plot.py +++ b/batdetect2/plot.py @@ -5,6 +5,7 @@ from typing import List, Optional, Tuple, Union, cast import numpy as np import torch from matplotlib import axes, patches +import matplotlib.ticker as tick from matplotlib import pyplot as plt from batdetect2.detector.parameters import DEFAULT_PROCESSING_CONFIGURATIONS @@ -91,7 +92,12 @@ def spectrogram( ax.imshow(spec, aspect="auto", origin="lower", cmap=cmap, extent=extent) ax.set_xlabel("Time (s)") - ax.set_ylabel("Frequency (Hz)") + ax.set_ylabel("Frequency (kHz)") + + def y_fmt(x, _): + return f"{x / 1000:d}" + + ax.yaxis.set_major_formatter(tick.FuncFormatter(y_fmt)) return ax