530 lines
17 KiB
Python
530 lines
17 KiB
Python
import plotstyle_plt
|
|
import numpy as np
|
|
import matplotlib.pyplot as plt
|
|
from itertools import product
|
|
from thunderhopper.filetools import search_files
|
|
from thunderhopper.modeltools import load_data
|
|
from thunderhopper.filtertools import find_kern_specs
|
|
from misc_functions import get_saturation, reduce_kernel_set, exclude_zero_scale,\
|
|
divide_by_zero, x_dist, y_dist
|
|
from color_functions import load_colors
|
|
from plot_functions import hide_axis, reorder_by_sd, ylimits, super_xlabel, ylabel, title_subplot,\
|
|
plot_line, strip_zeros, time_bar, assign_colors,\
|
|
letter_subplot, letter_subplots, hide_ticks
|
|
from IPython import embed
|
|
|
|
def plot_snippets(axes, time, snippets, ymin=None, ymax=None, **kwargs):
|
|
ymin, ymax = ylimits(snippets, minval=ymin, maxval=ymax, pad=0.05)
|
|
handles = []
|
|
for i, ax in enumerate(axes):
|
|
handles.append(plot_line(ax, time, snippets[:, ..., i],
|
|
ymin=ymin, ymax=ymax, **kwargs))
|
|
return handles
|
|
|
|
def plot_curves(ax, scales, measures, **kwargs):
|
|
if measures.ndim == 1:
|
|
handles = ax.plot(scales, measures, **kwargs)
|
|
return handles, measures
|
|
median_measure = np.nanmedian(measures, axis=1)
|
|
line_handle = ax.plot(scales, median_measure, **kwargs)[0]
|
|
return line_handle, median_measure
|
|
|
|
|
|
# GENERAL SETTINGS:
|
|
target_species = [
|
|
'Chorthippus_biguttulus',
|
|
'Chorthippus_mollis',
|
|
'Chrysochraon_dispar',
|
|
'Euchorthippus_declivus',
|
|
'Gomphocerippus_rufus',
|
|
'Omocestus_rufipes',
|
|
'Pseudochorthippus_parallelus',
|
|
][5]
|
|
example_file = {
|
|
'Chorthippus_biguttulus': 'Chorthippus_biguttulus_GBC_94-17s73.1ms-19s977ms',
|
|
'Chorthippus_mollis': 'Chorthippus_mollis_DJN_41_T28C-46s4.58ms-1m15s697ms',
|
|
'Chrysochraon_dispar': 'Chrysochraon_dispar_DJN_26_T28C_DT-32s134ms-34s432ms',
|
|
'Euchorthippus_declivus': 'Euchorthippus_declivus_FTN_79-2s167ms-2s563ms',
|
|
'Gomphocerippus_rufus': 'Gomphocerippus_rufus_FTN_91-3-884ms-10s427ms',
|
|
'Omocestus_rufipes': 'Omocestus_rufipes_DJN_32-40s724ms-48s779ms',
|
|
'Pseudochorthippus_parallelus': 'Pseudochorthippus_parallelus_GBC_88-6s678ms-9s32.3ms'
|
|
}[target_species]
|
|
stages = ['filt', 'env', 'log', 'inv', 'conv', 'feat']
|
|
data_path = search_files(example_file, dir='../data/inv/full/')[0]
|
|
save_path = '../figures/fig_invariance_full.pdf'
|
|
|
|
# ANALYSIS SETTINGS:
|
|
exclude_zero = True
|
|
thresh_rel = np.array([0, 0.5, 1, 1.5, 2, 2.5, 3])[4]
|
|
scale_subset_kwargs = dict(
|
|
combis=[['measure'], stages],
|
|
)
|
|
kern_subset_kwargs = dict(
|
|
combis=[['measure', 'snip'], ['conv', 'feat']],
|
|
keys=['thresh_abs'],
|
|
)
|
|
|
|
# SUBSET SETTINGS:
|
|
types = np.array([1, -1, 2, -2, 3, -3, 4, -4])
|
|
# types = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10]
|
|
sigmas = np.array([0.001, 0.002, 0.004, 0.008, 0.016])
|
|
# sigmas = [0.001, 0.002, 0.004, 0.008, 0.016, 0.032]
|
|
kernels = None
|
|
reduce_kernels = any(var is not None for var in [kernels, types, sigmas])
|
|
|
|
# GRAPH SETTINGS:
|
|
fig_kwargs = dict(
|
|
figsize=(32/2.54, 32/2.54),
|
|
)
|
|
super_grid_kwargs = dict(
|
|
nrows=2,
|
|
ncols=2,
|
|
wspace=0,
|
|
hspace=0,
|
|
left=0,
|
|
right=1,
|
|
bottom=0,
|
|
top=1,
|
|
height_ratios=[1, 1]
|
|
)
|
|
subfig_specs = dict(
|
|
snip=(0, slice(None)),
|
|
raw=(1, 0),
|
|
base=(1, 1),
|
|
)
|
|
snip_grid_kwargs = dict(
|
|
nrows=len(stages),
|
|
ncols=None,
|
|
wspace=0.1,
|
|
hspace=0.4,
|
|
left=0.13,
|
|
right=0.98,
|
|
bottom=0.05,
|
|
top=0.95
|
|
)
|
|
raw_grid_kwargs = dict(
|
|
nrows=2,
|
|
ncols=1,
|
|
wspace=0,
|
|
hspace=0.15,
|
|
left=0.14,
|
|
right=0.9,
|
|
bottom=0.1,
|
|
top=0.95,
|
|
height_ratios=[0.8, 0.2]
|
|
)
|
|
base_grid_kwargs = dict(
|
|
nrows=4,
|
|
ncols=1,
|
|
wspace=0,
|
|
hspace=0.25,
|
|
left=raw_grid_kwargs['left'],
|
|
right=raw_grid_kwargs['right'],
|
|
bottom=raw_grid_kwargs['bottom'],
|
|
top=raw_grid_kwargs['top'],
|
|
)
|
|
inset_bounds = [1.01, 0, 0.95, 1]
|
|
|
|
# PLOT SETTINGS:
|
|
fs = dict(
|
|
lab_norm=16,
|
|
lab_tex=20,
|
|
letter=22,
|
|
tit_norm=16,
|
|
tit_tex=20,
|
|
bar=16,
|
|
)
|
|
stage_colors = load_colors('../data/stage_colors.npz')
|
|
kern_colors = dict(
|
|
conv=load_colors('../data/conv_colors_subset.npz'),
|
|
feat=load_colors('../data/feat_colors_subset.npz')
|
|
)
|
|
lw = dict(
|
|
filt=0.25,
|
|
env=0.25,
|
|
log=0.25,
|
|
inv=0.25,
|
|
conv=0.25,
|
|
feat=1,
|
|
single=3,
|
|
swarm=1,
|
|
plateau=1.5,
|
|
legend=5,
|
|
dist=1
|
|
)
|
|
xlabels = dict(
|
|
big='scale $\\alpha$',
|
|
)
|
|
ylabels = dict(
|
|
filt='$x_{\\text{filt}}$\n$[\\text{a.u.}]$',
|
|
env='$x_{\\text{env}}$\n$[\\text{a.u.}]$',
|
|
log='$x_{\\text{log}}$\n$[\\text{dB}]$',
|
|
inv='$x_{\\text{adapt}}$\n$[\\text{dB}]$',
|
|
conv='$c_i$\n$[\\text{dB}]$',
|
|
feat='$f_i$',
|
|
raw=['$m$', '$\\mu_{f_i}$'],
|
|
base=['$m\\,/\\,m_{\\eta}$', '$\\sigma_{c_i}\\,/\\,\\sigma_{\\eta_i}$', '$\\mu_{f_i}\\,/\\,\\mu_{\\eta_i}$', '$\\text{PDF}_{\\alpha}$']
|
|
)
|
|
xlab_big_kwargs = dict(
|
|
y=0,
|
|
fontsize=fs['lab_norm'],
|
|
ha='center',
|
|
va='bottom',
|
|
)
|
|
ylab_snip_kwargs = dict(
|
|
x=0.03,
|
|
fontsize=fs['lab_tex'],
|
|
rotation=0,
|
|
ha='center',
|
|
va='center',
|
|
ma='center'
|
|
)
|
|
ylab_big_kwargs = dict(
|
|
x=0,
|
|
fontsize=fs['lab_norm'],
|
|
ha='center',
|
|
va='top',
|
|
)
|
|
yloc = dict(
|
|
filt=3000,
|
|
env=1000,
|
|
log=50,
|
|
inv=20,
|
|
conv=1,
|
|
feat=1,
|
|
)
|
|
title_kwargs = dict(
|
|
x=0.5,
|
|
yref=1,
|
|
ha='center',
|
|
va='top',
|
|
fontsize=fs['tit_norm'],
|
|
)
|
|
letter_snip_kwargs = dict(
|
|
x=0,
|
|
yref=0.5,
|
|
ha='left',
|
|
va='center',
|
|
fontsize=fs['letter'],
|
|
)
|
|
letter_big_kwargs = dict(
|
|
xref=0,
|
|
y=1,
|
|
ha='left',
|
|
va='center',
|
|
fontsize=fs['letter'],
|
|
)
|
|
bar_time = 5
|
|
bar_kwargs = dict(
|
|
dur=bar_time,
|
|
y0=-0.3,
|
|
y1=-0.15,
|
|
xshift=1,
|
|
color='k',
|
|
lw=0,
|
|
clip_on=False,
|
|
text_pos=(-0.1, 0.5),
|
|
text_str=f'${bar_time}\\,\\text{{s}}$',
|
|
text_kwargs=dict(
|
|
fontsize=fs['bar'],
|
|
ha='right',
|
|
va='center',
|
|
)
|
|
)
|
|
leg_kwargs = dict(
|
|
ncols=1,
|
|
loc='upper left',
|
|
bbox_to_anchor=(0.025, 0.5, 0.5, 0.5),
|
|
frameon=False,
|
|
prop=dict(
|
|
size=20,
|
|
),
|
|
borderpad=0,
|
|
borderaxespad=0,
|
|
handlelength=1,
|
|
columnspacing=1,
|
|
handletextpad=0.5,
|
|
labelspacing=0.1
|
|
)
|
|
leg_labels = dict(
|
|
filt='$x_{\\text{filt}}$',
|
|
env='$x_{\\text{env}}$',
|
|
log='$x_{\\text{log}}$',
|
|
inv='$x_{\\text{adapt}}$',
|
|
conv='$c_i$',
|
|
feat='$f_i$'
|
|
)
|
|
dist_line_kwargs = dict(
|
|
lw=lw['dist'],
|
|
)
|
|
dist_fill_kwargs = dict(
|
|
lw=lw['dist'],
|
|
)
|
|
plateau_settings = dict(
|
|
low=0.05,
|
|
high=0.95,
|
|
first=True,
|
|
last=True,
|
|
condense=None,
|
|
)
|
|
plateau_line_kwargs = dict(
|
|
lw=lw['plateau'],
|
|
ls='--',
|
|
zorder=1,
|
|
)
|
|
plateau_dot_kwargs = dict(
|
|
marker='o',
|
|
markersize=8,
|
|
markeredgewidth=1,
|
|
clip_on=False,
|
|
)
|
|
|
|
# EXECUTION:
|
|
|
|
# Load invariance data:
|
|
data, config = load_data(data_path, keywords=['snip', 'scales', 'measure', 'thresh'])
|
|
t_full = np.arange(data['snip_filt'].shape[0]) / config['rate']
|
|
|
|
# Reduce kernels:
|
|
if reduce_kernels:
|
|
kern_inds = find_kern_specs(config['k_specs'], kernels, types, sigmas)
|
|
data = reduce_kernel_set(data, kern_inds, **kern_subset_kwargs)
|
|
config['k_specs'] = config['k_specs'][kern_inds, :]
|
|
config['kernels'] = config['kernels'][:, kern_inds]
|
|
|
|
# Reduce thresholds:
|
|
thresh_ind = np.nonzero(data['thresh_rel'] == thresh_rel)[0][0]
|
|
data['measure_feat'] = data['measure_feat'][:, :, thresh_ind]
|
|
data['snip_feat'] = data['snip_feat'][:, :, :, thresh_ind]
|
|
|
|
# Remember pure-noise reference measures:
|
|
ref_data = {stage: data[f'measure_{stage}'][0, ...] for stage in stages}
|
|
|
|
# Reduce scales:
|
|
if exclude_zero:
|
|
data = exclude_zero_scale(data, **scale_subset_kwargs)
|
|
scales = data['scales']
|
|
snip_scales = data['example_scales']
|
|
|
|
# Adjust grid parameters:
|
|
snip_grid_kwargs['ncols'] = snip_scales.size
|
|
|
|
# Prepare overall graph:
|
|
fig = plt.figure(**fig_kwargs)
|
|
super_grid = fig.add_gridspec(**super_grid_kwargs)
|
|
|
|
# Prepare stage-specific snippet axes:
|
|
snip_subfig = fig.add_subfigure(super_grid[subfig_specs['snip']])
|
|
snip_grid = snip_subfig.add_gridspec(**snip_grid_kwargs)
|
|
snip_axes = np.zeros((snip_grid.nrows, snip_grid.ncols), dtype=object)
|
|
for i, j in product(range(snip_grid.nrows), range(snip_grid.ncols)):
|
|
ax = snip_subfig.add_subplot(snip_grid[i, j])
|
|
ax.set_xlim(t_full[0], t_full[-1])
|
|
ax.yaxis.set_major_locator(plt.MultipleLocator(yloc[stages[i]]))
|
|
hide_axis(ax, 'bottom')
|
|
if i == 0:
|
|
title = title_subplot(ax, f'$\\alpha={strip_zeros(snip_scales[j])}$',
|
|
ref=snip_subfig, **title_kwargs)
|
|
if j == 0:
|
|
ylabel(ax, ylabels[stages[i]], **ylab_snip_kwargs, transform=snip_subfig.transSubfigure)
|
|
else:
|
|
hide_axis(ax, 'left')
|
|
snip_axes[i, j] = ax
|
|
time_bar(snip_axes[-1, -1], **bar_kwargs)
|
|
letter_subplot(snip_subfig, 'a', ref=title, **letter_snip_kwargs)
|
|
|
|
# Prepare raw analysis axes:
|
|
raw_subfig = fig.add_subfigure(super_grid[subfig_specs['raw']])
|
|
raw_grid = raw_subfig.add_gridspec(**raw_grid_kwargs)
|
|
raw_axes = np.zeros((raw_grid.nrows,), dtype=object)
|
|
for i in range(raw_grid.nrows):
|
|
ax = raw_subfig.add_subplot(raw_grid[i, 0])
|
|
ax.set_xlim(scales[0], scales[-1])
|
|
ax.set_xscale('symlog', linthresh=scales[1], linscale=0.5)
|
|
ylabel(ax, ylabels['raw'][i], transform=raw_subfig.transSubfigure, **ylab_big_kwargs)
|
|
if i == 0:
|
|
ax.set_yscale('symlog', linthresh=0.001, linscale=0.1)
|
|
hide_ticks(ax, 'bottom')
|
|
else:
|
|
transform = raw_subfig.transSubfigure + ax.transAxes.inverted()
|
|
inset_x1 = transform.transform((inset_bounds[2], 0))[0]
|
|
inset_bounds[2] = inset_x1 - inset_bounds[0]
|
|
raw_inset = ax.inset_axes(inset_bounds)
|
|
raw_inset.axis('off')
|
|
raw_axes[i] = ax
|
|
letter_subplots(raw_axes, 'bc', ref=raw_subfig, **letter_big_kwargs)
|
|
|
|
# Prepare base analysis axes:
|
|
base_subfig = fig.add_subfigure(super_grid[subfig_specs['base']])
|
|
base_grid = base_subfig.add_gridspec(**base_grid_kwargs)
|
|
base_axes = np.zeros((base_grid.nrows,), dtype=object)
|
|
base_insets = np.zeros((base_grid.nrows - 1,), dtype=object)
|
|
for i in range(base_grid.nrows):
|
|
ax = base_subfig.add_subplot(base_grid[i, 0])
|
|
ax.set_xlim(scales[0], scales[-1])
|
|
ax.set_xscale('symlog', linthresh=scales[1], linscale=0.5)
|
|
ylabel(ax, ylabels['base'][i], transform=base_subfig.transSubfigure, **ylab_big_kwargs)
|
|
if i < base_grid_kwargs['nrows'] - 1:
|
|
ax.set_yscale('symlog', linthresh=0.01, linscale=0.1)
|
|
hide_ticks(ax, 'bottom')
|
|
if i in [1, 2]:
|
|
inset = ax.inset_axes(inset_bounds)
|
|
inset.set_yscale('symlog', linthresh=0.01, linscale=0.1)
|
|
inset.axis('off')
|
|
base_insets[i - 1] = inset
|
|
base_axes[i] = ax
|
|
letter_subplots(base_axes, 'defg', ref=base_subfig, **letter_big_kwargs)
|
|
super_xlabel(xlabels['big'], fig, raw_axes[-1], base_axes[-1],
|
|
left_fig=raw_subfig, right_fig=base_subfig, **xlab_big_kwargs)
|
|
|
|
if True:
|
|
# Plot filtered snippets:
|
|
plot_snippets(snip_axes[0, :], t_full, data['snip_filt'],
|
|
c=stage_colors['filt'], lw=lw['filt'])
|
|
|
|
# Plot envelope snippets:
|
|
plot_snippets(snip_axes[1, :], t_full, data['snip_env'],
|
|
ymin=0, c=stage_colors['env'], lw=lw['env'])
|
|
|
|
# Plot logarithmic snippets:
|
|
plot_snippets(snip_axes[2, :], t_full, data['snip_log'],
|
|
c=stage_colors['log'], lw=lw['log'])
|
|
|
|
# Plot invariant snippets:
|
|
plot_snippets(snip_axes[3, :], t_full, data['snip_inv'],
|
|
c=stage_colors['inv'], lw=lw['inv'])
|
|
|
|
# Plot kernel response snippets:
|
|
all_handles = plot_snippets(snip_axes[4, :], t_full, data['snip_conv'],
|
|
c=stage_colors['conv'], lw=lw['conv'])
|
|
for i, handles in enumerate(all_handles):
|
|
assign_colors(handles, config['k_specs'][:, 0], kern_colors['conv'])
|
|
reorder_by_sd(handles, data['snip_conv'][..., i])
|
|
|
|
# Plot feature snippets:
|
|
all_handles = plot_snippets(snip_axes[5, :], t_full, data['snip_feat'],
|
|
ymin=0, ymax=1, c=stage_colors['feat'], lw=lw['feat'])
|
|
for i, handles in enumerate(all_handles):
|
|
assign_colors(handles, config['k_specs'][:, 0], kern_colors['feat'])
|
|
reorder_by_sd(handles, data['snip_feat'][..., i])
|
|
|
|
# Plot analysis results:
|
|
crit_inds, crit_scales_single, crit_scales_swarm = {}, {}, {}
|
|
max_pdf = -np.inf
|
|
leg_handles = []
|
|
for stage in stages:
|
|
mkey = f'measure_{stage}'
|
|
measure = data[mkey]
|
|
color = stage_colors[stage]
|
|
|
|
## UNNORMALIZED MEASURE:
|
|
|
|
# Plot single raw intensity curve (median where necessary):
|
|
handles, curve = plot_curves(raw_axes[0], scales, measure, c=color, lw=lw['single'])
|
|
|
|
# Add stage-specific proxy legend artist:
|
|
leg_handles.append(raw_axes[0].plot([], [], c=color, label=leg_labels[stage])[0])
|
|
|
|
# Plot curve swarm:
|
|
if stage == 'feat':
|
|
# Sync y-limits:
|
|
ylimits(measure, raw_axes[1], minval=0, pad=0.05)
|
|
raw_inset.set_ylim(raw_axes[1].get_ylim())
|
|
# Plot swarm:
|
|
handles = raw_axes[1].plot(scales, measure, lw=lw['swarm'])
|
|
assign_colors(handles, config['k_specs'][:, 0], kern_colors[stage])
|
|
reorder_by_sd(handles, measure)
|
|
# Plot distribution of saturation levels:
|
|
line_kwargs = dist_line_kwargs | dict(c=color)
|
|
fill_kwargs = dist_fill_kwargs | dict(color=color)
|
|
y_dist(raw_inset, measure[-1], nbins=75, log=False,
|
|
line_kwargs=line_kwargs, fill_kwargs=fill_kwargs)
|
|
|
|
# Indicate saturation point(s):
|
|
if stage in ['log', 'inv', 'conv', 'feat']:
|
|
ind = get_saturation(curve, **plateau_settings)[1]
|
|
crit_inds[stage] = ind
|
|
scale = scales[ind]
|
|
crit_scales_single[stage] = scale
|
|
raw_axes[0].plot(scale, 0, c='w', alpha=1, zorder=5.5, **plateau_dot_kwargs,
|
|
transform=raw_axes[0].get_xaxis_transform())
|
|
raw_axes[0].plot(scale, 0, mfc=color, mec='k', alpha=0.75, zorder=6, **plateau_dot_kwargs,
|
|
transform=raw_axes[0].get_xaxis_transform())
|
|
raw_axes[0].vlines(scale, raw_axes[0].get_ylim()[0], curve[ind],
|
|
color=color, **plateau_line_kwargs)
|
|
|
|
## NORMALIZED MEASURE:
|
|
|
|
# Relate to noise baseline:
|
|
measure = divide_by_zero(data[mkey], ref_data[stage])
|
|
|
|
# Plot single baseline-normalized intensity curve (median where necessary):
|
|
handles, curve = plot_curves(base_axes[0], scales, measure, c=color, lw=lw['single'])
|
|
|
|
# Plot curve swarm:
|
|
if stage in ['conv', 'feat']:
|
|
i0, i1 = (1, 0) if stage == 'conv' else (2, 1)
|
|
# Sync y-limits:
|
|
ylimits(measure, base_axes[i0], minval=0.9, pad=0.05)
|
|
base_insets[i1].set_ylim(base_axes[i0].get_ylim())
|
|
# Plot swarm:
|
|
handles = base_axes[i0].plot(scales, measure, lw=lw['swarm'])
|
|
assign_colors(handles, config['k_specs'][:, 0], kern_colors[stage])
|
|
reorder_by_sd(handles, measure)
|
|
# Plot distribution of saturation levels:
|
|
line_kwargs = dist_line_kwargs | dict(c=color)
|
|
fill_kwargs = dist_fill_kwargs | dict(color=color)
|
|
y_dist(base_insets[i1], measure[-1], nbins=100, log=True,
|
|
line_kwargs=line_kwargs, fill_kwargs=fill_kwargs)
|
|
# Get and log distribution of saturation points:
|
|
inds = np.array(get_saturation(measure, **plateau_settings)[1])
|
|
if np.isnan(inds).sum():
|
|
inds = inds[~np.isnan(inds)].astype(int)
|
|
crit_scales_swarm[stage] = scales[inds]
|
|
if stage == 'feat':
|
|
# Plot distribution of saturation points on shared bins:
|
|
bin_lims = [0.01, 1.1 * max([s.max() for s in crit_scales_swarm.values()])]
|
|
for temp_stage, crit_scales in crit_scales_swarm.items():
|
|
z = 3 if temp_stage == 'conv' else 2
|
|
line_kwargs = dist_line_kwargs | dict(c=stage_colors[temp_stage], zorder=z)
|
|
fill_kwargs = dist_fill_kwargs | dict(color=stage_colors[temp_stage], alpha=0.25, zorder=z)
|
|
pdf = x_dist(base_axes[-1], crit_scales, nbins=75, limits=bin_lims,
|
|
log=True, line_kwargs=line_kwargs, fill_kwargs=fill_kwargs)[0]
|
|
max_pdf = max(max_pdf, pdf.max())
|
|
base_axes[-1].set_ylim(0, max_pdf * 1.05)
|
|
# Add single curve saturation point:
|
|
for temp_stage, crit_scale in crit_scales_single.items():
|
|
base_axes[-1].plot(crit_scale, 0, c='w', alpha=1, zorder=5.5, **plateau_dot_kwargs,
|
|
transform=base_axes[-1].get_xaxis_transform())
|
|
base_axes[-1].plot(crit_scale, 0, mfc=stage_colors[temp_stage], mec='k', alpha=0.75,
|
|
zorder=6, **plateau_dot_kwargs,
|
|
transform=base_axes[-1].get_xaxis_transform())
|
|
|
|
# Indicate saturation point(s):
|
|
if stage in ['log', 'inv', 'conv', 'feat']:
|
|
ind = crit_inds[stage]
|
|
scale = crit_scales_single[stage]
|
|
base_axes[0].plot(scale, 0, c='w', alpha=1, zorder=5.5, **plateau_dot_kwargs,
|
|
transform=base_axes[0].get_xaxis_transform())
|
|
base_axes[0].plot(scale, 0, mfc=color, mec='k', alpha=0.75, zorder=6, **plateau_dot_kwargs,
|
|
transform=base_axes[0].get_xaxis_transform())
|
|
base_axes[0].vlines(scale, base_axes[0].get_ylim()[0], curve[ind],
|
|
color=color, **plateau_line_kwargs)
|
|
|
|
# Posthoc adjustments:
|
|
raw_axes[0].set_ylim(bottom=0.001)
|
|
base_axes[0].set_ylim(1, 100)
|
|
|
|
# Add legend to first analysis axis:
|
|
legend = raw_axes[0].legend(handles=leg_handles, **leg_kwargs)
|
|
[handle.set_lw(lw['legend']) for handle in legend.get_lines()]
|
|
|
|
# Save graph:
|
|
if save_path is not None:
|
|
file_name = save_path.replace('.pdf', f'_{target_species}.pdf')
|
|
fig.savefig(file_name)
|
|
plt.show()
|
|
|
|
print('Done.')
|
|
embed()
|