Made fig_invariance_rect_lp.pdf and corresponding appendix figure.
Adjusted fig_invariance_log_hp.pdf with 2nd yaxis in dB. Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
@@ -7,8 +7,8 @@ from thunderhopper.modeltools import load_data
|
||||
from misc_functions import shorten_species, get_saturation
|
||||
from color_functions import load_colors
|
||||
from plot_functions import hide_axis, ylimits, super_xlabel, ylabel, hide_ticks,\
|
||||
plot_line, strip_zeros, time_bar, zoom_inset,\
|
||||
letter_subplot, letter_subplots, title_subplot
|
||||
plot_line, strip_zeros, time_bar, zoom_inset, shift_subplot,\
|
||||
letter_subplot, letter_subplots, title_subplot, color_axis
|
||||
from IPython import embed
|
||||
|
||||
def add_snip_axes(fig, grid_kwargs):
|
||||
@@ -27,10 +27,10 @@ def plot_snippets(axes, time, snippets, ymin=None, ymax=None, **kwargs):
|
||||
handles.extend(plot_line(ax, time, snippet, ymin=ymin, ymax=ymax, **kwargs))
|
||||
return handles
|
||||
|
||||
|
||||
# GENERAL SETTINGS:
|
||||
target = 'Omocestus_rufipes_DJN_32-40s724ms-48s779ms'
|
||||
data_path = search_files(target, excl='noise', dir='../data/inv/log_hp/')[0]
|
||||
ref_path = '../data/inv/log_hp/ref_measures.npz'
|
||||
save_path = '../figures/fig_invariance_log_hp.pdf'
|
||||
target_species = [
|
||||
'Chorthippus_biguttulus',
|
||||
@@ -46,7 +46,7 @@ load_kwargs = dict(
|
||||
files=stages,
|
||||
keywords=['scales', 'snip', 'measure']
|
||||
)
|
||||
compute_ratios = True
|
||||
relate_to_noise = True
|
||||
exclude_zero = True
|
||||
show_diag = True
|
||||
show_plateaus = True
|
||||
@@ -79,7 +79,7 @@ pure_grid_kwargs = dict(
|
||||
wspace=0.1,
|
||||
hspace=0.15,
|
||||
left=0.11,
|
||||
right=0.95,
|
||||
right=0.98,
|
||||
bottom=1 - block_height - edge_padding,
|
||||
top=1 - edge_padding,
|
||||
height_ratios=[1, 2, 1]
|
||||
@@ -95,14 +95,15 @@ noise_grid_kwargs = dict(
|
||||
top=edge_padding + block_height,
|
||||
height_ratios=[1, 2, 1]
|
||||
)
|
||||
big_col_shift = -0.12
|
||||
big_grid_kwargs = dict(
|
||||
nrows=1,
|
||||
ncols=3,
|
||||
wspace=0.3,
|
||||
wspace=0.25,
|
||||
hspace=0,
|
||||
left=pure_grid_kwargs['left'],
|
||||
left=pure_grid_kwargs['left'] - big_col_shift,
|
||||
right=pure_grid_kwargs['right'],
|
||||
bottom=0.05,
|
||||
bottom=0.03,
|
||||
top=1
|
||||
)
|
||||
anchor_kwargs = dict(
|
||||
@@ -137,7 +138,9 @@ ylabels = dict(
|
||||
env='$x_{\\text{env}}$',
|
||||
log='$x_{\\text{dB}}$',
|
||||
inv='$x_{\\text{adapt}}$',
|
||||
big='$\\sigma_x\\,/\\,\\sigma_{\\eta}$',
|
||||
big_pure='$\\sigma_x$',
|
||||
big_log='$\\sigma_x\\,[\\text{dB}]$',
|
||||
big_noise='$\\sigma_x\\,/\\,\\sigma_{\\eta}$' if relate_to_noise else None,
|
||||
)
|
||||
xlab_big_kwargs = dict(
|
||||
y=0,
|
||||
@@ -145,6 +148,18 @@ xlab_big_kwargs = dict(
|
||||
ha='center',
|
||||
va='bottom',
|
||||
)
|
||||
ylab_big_left_kwargs = dict(
|
||||
x=-0.2,
|
||||
fontsize=fs['lab_tex'],
|
||||
ha='center',
|
||||
va='bottom'
|
||||
)
|
||||
ylab_big_right_kwargs = dict(
|
||||
x=1.2,
|
||||
fontsize=fs['lab_tex'],
|
||||
ha='center',
|
||||
va='top'
|
||||
)
|
||||
ylab_snip_kwargs = dict(
|
||||
x=0,
|
||||
fontsize=fs['lab_tex'],
|
||||
@@ -152,12 +167,6 @@ ylab_snip_kwargs = dict(
|
||||
ha='left',
|
||||
va='center',
|
||||
)
|
||||
ylab_big_kwargs = dict(
|
||||
x=0,
|
||||
fontsize=fs['lab_tex'],
|
||||
ha='center',
|
||||
va='top',
|
||||
)
|
||||
yloc = dict(
|
||||
env=1000,
|
||||
log=40,
|
||||
@@ -233,7 +242,7 @@ leg_kwargs = dict(
|
||||
),
|
||||
borderpad=0,
|
||||
borderaxespad=0,
|
||||
handlelength=1,
|
||||
handlelength=0.5,
|
||||
columnspacing=1,
|
||||
)
|
||||
diag_kwargs = dict(
|
||||
@@ -287,11 +296,7 @@ noise_data, _ = load_data(data_path.replace('pure', 'noise'), **load_kwargs)
|
||||
pure_scales, noise_scales = pure_data['scales'], noise_data['scales']
|
||||
t_full = np.arange(pure_data['snip_env'].shape[0]) / config['env_rate']
|
||||
|
||||
if compute_ratios:
|
||||
# Relate pure-song measures to near-zero scale:
|
||||
pure_data['measure_env'] /= pure_data['measure_env'][1]
|
||||
pure_data['measure_log'] /= pure_data['measure_log'][1]
|
||||
pure_data['measure_inv'] /= pure_data['measure_inv'][1]
|
||||
if relate_to_noise:
|
||||
# Relate noise-song measures to zero scale:
|
||||
noise_data['measure_env'] /= noise_data['measure_env'][0]
|
||||
noise_data['measure_log'] /= noise_data['measure_log'][0]
|
||||
@@ -354,8 +359,10 @@ big_axes = np.zeros((big_grid.ncols,), dtype=object)
|
||||
for i, scales in enumerate([pure_scales, noise_scales, noise_scales]):
|
||||
ax = big_subfig.add_subplot(big_grid[0, i])
|
||||
ax.set_xlim(scales[0], scales[-1])
|
||||
ax.set_ylim(scales[0], scales[-1])
|
||||
ax.set_xscale('symlog', linthresh=scales[1], linscale=0.5)
|
||||
ax.set_yscale('symlog', linthresh=scales[1], linscale=0.5)
|
||||
# ax.xaxis.set_major_locator(plt.LogLocator(base=10, subs=[1]))
|
||||
ax.set_aspect(**anchor_kwargs)
|
||||
if i in [0, 1]:
|
||||
ax.set_ylim(scales[0], scales[-1])
|
||||
@@ -365,10 +372,19 @@ for i, scales in enumerate([pure_scales, noise_scales, noise_scales]):
|
||||
ax.set_aspect('auto', adjustable='box', anchor=(0.5, 0.5))
|
||||
ax.set_position([pos_auto[0], pos_equal[1], pos_auto[2], pos_equal[3]])
|
||||
ax.set_ylim(0.9, 30)
|
||||
if i == 1:
|
||||
hide_ticks(ax, 'left')
|
||||
big_axes[i] = ax
|
||||
ylabel(big_axes[0], ylabels['big'], transform=big_subfig.transSubfigure, **ylab_big_kwargs)
|
||||
shift_subplot(big_axes[0], dx=big_col_shift)
|
||||
ylabel(big_axes[0], ylabels['big_pure'], transform=big_axes[0].transAxes, **ylab_big_left_kwargs)
|
||||
ylabel(big_axes[1], ylabels['big_noise'], transform=big_axes[1].transAxes, **ylab_big_left_kwargs)
|
||||
big_twin = big_axes[0].twinx()
|
||||
hide_axis(big_twin, 'left')
|
||||
big_twin.spines['right'].set_visible(True)
|
||||
big_twin.set_position(big_axes[0].get_position().bounds)
|
||||
big_twin.set_ylim(scales[0], scales[-1])
|
||||
big_twin.set_yscale('symlog', linthresh=scales[1], linscale=0.5)
|
||||
ylabel(big_twin, ylabels['big_log'], transform=big_twin.transAxes, **ylab_big_right_kwargs)
|
||||
color_axis(big_axes[0], colors['env'], side='left')
|
||||
color_axis(big_twin, colors['log'], side='right')
|
||||
super_xlabel(xlabels['big'], big_subfig, big_axes[0], big_axes[-1], **xlab_big_kwargs)
|
||||
letter_subplots(big_axes, 'cde', **letter_big_kwargs)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user