Fetched bunch of species-specific song snippets.

Worked those into LogHP analysis.
Worked results into fig_invariance_log-hp.pdf.
Put details into new fig_invariance_log-hp_species.pdf (appendix).
This commit is contained in:
j-hartling
2026-04-14 17:30:58 +02:00
parent 0b9264b1e1
commit 36ac504efa
17 changed files with 490 additions and 205 deletions

View File

@@ -2,6 +2,7 @@ import string
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.transforms import Bbox, BboxTransformTo, TransformedBbox
from misc_functions import get_kde
def hide_ticks(ax, side='bottom', ticks=True):
axis = 'x' if side in ['top', 'bottom'] else 'y'
@@ -298,3 +299,33 @@ def zoom_inset(ax, inset, handle, x0=None, x1=None, y0=None, y1=None, ref='x',
def set_clip_box(artist, ax, bounds=[[0, -0.05], [1, 1.05]]):
artist.set_clip_box(TransformedBbox(Bbox(bounds), ax.transAxes))
return None
def plot_dist_shifted(ax, data, axis, pdf=None, sigma=0.1, which='x',
base=None, cap=None, add_pdf=False, shifted=False, **kwargs):
if pdf is None:
pdf, axis = get_kde(data, sigma, axis)
if base is None:
base = pdf.min()
if cap is None:
cap = pdf.max()
pdf = (pdf - pdf.min()) / (pdf.max() - pdf.min()) * (cap - base) + base
if which == 'x':
transform = ax.get_xaxis_transform()
elif which == 'y':
transform = ax.get_yaxis_transform()
else:
transform = ax.transData
rng = np.random.default_rng()
handles = []
for value in data:
ind = np.nonzero(axis == value)[0][0]
offset = base if not shifted else rng.uniform(base, pdf[ind])
variables = (offset, value) if which=='y' else (value, offset)
handles.extend(ax.plot(*variables, transform=transform, **kwargs))
if add_pdf:
variables = (pdf, axis) if which=='y' else (axis, pdf)
pdf_handle = ax.plot(*variables, transform=transform, c='k', lw=1)
return handles, pdf_handle
return handles