Added and described two single-kernel Thresh-LP invariance figures in main.tex.
This commit is contained in:
@@ -6,7 +6,8 @@ from thunderhopper.filetools import search_files
|
||||
from thunderhopper.modeltools import load_data
|
||||
from color_functions import load_colors
|
||||
from plot_functions import hide_axis, ylimits, xlabel, ylabel,\
|
||||
plot_line, strip_zeros, time_bar
|
||||
plot_line, strip_zeros, time_bar,\
|
||||
letter_subplot, letter_subplots
|
||||
from IPython import embed
|
||||
|
||||
def add_snip_axes(fig, grid_kwargs):
|
||||
@@ -128,26 +129,17 @@ xloc = dict(
|
||||
)
|
||||
letter_snip_kwargs = dict(
|
||||
x=0.02,
|
||||
y=1,
|
||||
y=0.97,
|
||||
ha='left',
|
||||
va='top',
|
||||
fontsize=22,
|
||||
fontweight='bold'
|
||||
)
|
||||
letter_analysis_kwargs = dict(
|
||||
x=0,
|
||||
y=1,
|
||||
yref=letter_snip_kwargs['y'],
|
||||
ha='left',
|
||||
va='top',
|
||||
fontsize=22,
|
||||
fontweight='bold'
|
||||
)
|
||||
indicate_unsaturated = False
|
||||
unsaturated_proportion = 0.85
|
||||
unsaturated_kwargs = dict(
|
||||
color=3 * (0.85,),
|
||||
zorder=0,
|
||||
lw=0
|
||||
)
|
||||
bar_time = 5
|
||||
bar_kwargs = dict(
|
||||
@@ -179,7 +171,6 @@ for data_path in data_paths:
|
||||
transform=pure_subfig.transSubfigure)
|
||||
for ax, scale in zip(pure_axes[snip_specs['env']], pure_data['example_scales']):
|
||||
ax.set_title(f'$\\alpha={strip_zeros(scale)}$')
|
||||
pure_subfig.text(s='a', **letter_snip_kwargs)
|
||||
|
||||
# Prepare noise-song snippet axes:
|
||||
noise_subfig = fig.add_subfigure(super_grid[subfig_specs['noise']])
|
||||
@@ -191,7 +182,7 @@ for data_path in data_paths:
|
||||
transform=noise_subfig.transSubfigure)
|
||||
for ax, scale in zip(noise_axes[snip_specs['env']], noise_data['example_scales']):
|
||||
ax.set_title(f'$\\alpha={strip_zeros(scale)}$')
|
||||
noise_subfig.text(s='b', **letter_snip_kwargs)
|
||||
letter_subplots([pure_subfig, noise_subfig], **letter_snip_kwargs)
|
||||
|
||||
# Prepare analysis axis:
|
||||
analysis_subfig = fig.add_subfigure(super_grid[subfig_specs['analysis']])
|
||||
@@ -204,7 +195,7 @@ for data_path in data_paths:
|
||||
analysis_ax.set_yscale('log')
|
||||
ylabel(analysis_ax, ylabels['analysis'], **ylab_analysis_kwargs,
|
||||
transform=analysis_subfig.transSubfigure)
|
||||
analysis_subfig.text(s='c', **letter_analysis_kwargs)
|
||||
letter_subplot(analysis_subfig, 'c', **letter_analysis_kwargs, ref=pure_subfig)
|
||||
|
||||
# Plot pure-song envelope snippets:
|
||||
plot_snippets(pure_axes[snip_specs['env']], t_full, pure_data['env'],
|
||||
@@ -238,19 +229,9 @@ for data_path in data_paths:
|
||||
|
||||
# Plot pure-song SD ratios (ideal):
|
||||
base_ind = np.argmin(pure_data['scales'])
|
||||
# measure_env = pure_data['measure_env'] / pure_data['measure_env'][base_ind]
|
||||
# measure_log = pure_data['measure_log'] / pure_data['measure_log'][base_ind]
|
||||
measure_inv = pure_data['measure_inv'] / pure_data['measure_inv'][base_ind]
|
||||
# analysis_ax.plot(pure_data['scales'], measure_env, c=colors['env'], lw=lw_analysis, ls='--')
|
||||
# analysis_ax.plot(pure_data['scales'], measure_log, c=colors['log'], lw=lw_analysis, ls='--')
|
||||
analysis_ax.plot(pure_data['scales'], measure_inv, c=colors['inv'], lw=lw_analysis, ls='--')
|
||||
|
||||
if indicate_unsaturated:
|
||||
# Indicate influence of noise floor:
|
||||
limit = noise_data['limit'] * unsaturated_proportion
|
||||
thresh_ind = np.nonzero(noise_data['measure_inv'] <= limit)[0][-1]
|
||||
analysis_ax.axvspan(0, noise_data['scales'][thresh_ind], **unsaturated_kwargs)
|
||||
|
||||
# Plot noise-song SD ratios (limited):
|
||||
base_ind = np.argmin(noise_data['scales'])
|
||||
measure_env = noise_data['measure_env'] / noise_data['measure_env'][base_ind]
|
||||
|
||||
@@ -5,9 +5,10 @@ from itertools import product
|
||||
from thunderhopper.filetools import search_files
|
||||
from thunderhopper.modeltools import load_data
|
||||
from thunderhopper.filtertools import find_kern_specs
|
||||
from color_functions import load_colors
|
||||
from plot_functions import hide_axis, xlimits, ylimits, xlabel, ylabel, super_ylabel,\
|
||||
plot_line, plot_barcode, strip_zeros, time_bar
|
||||
from color_functions import load_colors, shade_colors
|
||||
from plot_functions import hide_axis, ylimits, xlabel, ylabel, super_ylabel,\
|
||||
plot_line, plot_barcode, strip_zeros, time_bar,\
|
||||
letter_subplot, letter_subplots
|
||||
from IPython import embed
|
||||
|
||||
def add_snip_axes(fig, grid_kwargs):
|
||||
@@ -19,10 +20,13 @@ def add_snip_axes(fig, grid_kwargs):
|
||||
[hide_axis(ax, 'bottom') for ax in axes.flatten()]
|
||||
return axes
|
||||
|
||||
def plot_snippets(axes, time, snippets, ymin=None, ymax=None, **kwargs):
|
||||
def plot_snippets(axes, time, snippets, ymin=None, ymax=None,
|
||||
thresh=None, fill_kwargs={}, **kwargs):
|
||||
ymin, ymax = ylimits(snippets, minval=ymin, maxval=ymax, pad=0.05)
|
||||
for ax, snippet in zip(axes, snippets.T):
|
||||
plot_line(ax, time, snippet, ymin=ymin, ymax=ymax, **kwargs)
|
||||
if thresh is not None:
|
||||
ax.fill_between(time, thresh, snippet, where=(snippet > thresh), **fill_kwargs)
|
||||
return None
|
||||
|
||||
def plot_bi_snippets(axes, time, binary, **kwargs):
|
||||
@@ -30,27 +34,29 @@ def plot_bi_snippets(axes, time, binary, **kwargs):
|
||||
plot_barcode(ax, time, binary[:, None], **kwargs)
|
||||
return None
|
||||
|
||||
def side_distributions(axes, snippets, inset_bounds, thresh,
|
||||
ymin=None, ymax=None):
|
||||
bins = np.linspace(snippets.min(), snippets.max(), 50)
|
||||
centers = bins[:-1] + (bins[1] - bins[0]) / 2
|
||||
def side_distributions(axes, snippets, inset_bounds, thresh, nbins=50,
|
||||
ymin=None, ymax=None, fill_kwargs={}, **kwargs):
|
||||
limits = np.array([snippets.min(), snippets.max()]) * 1.05
|
||||
edges = np.linspace(*limits, nbins + 1)
|
||||
centers = edges[:-1] + (edges[1] - edges[0]) / 2
|
||||
for ax, snippet in zip(axes, snippets.T):
|
||||
pdf, _ = np.histogram(snippet, edges, density=True)
|
||||
inset = ax.inset_axes(inset_bounds)
|
||||
inset.axis('off')
|
||||
pdf, _ = np.histogram(snippet, bins, density=True)
|
||||
inset.plot(pdf, centers, c='k', lw=1)
|
||||
inset.plot(pdf, centers, **kwargs)
|
||||
inset.fill_betweenx(centers, pdf.min(), pdf, where=(centers > thresh),
|
||||
color=colors['bi'], lw=0)
|
||||
inset.set_xlim(0, pdf.max())
|
||||
**fill_kwargs)
|
||||
ylimits(centers, inset, minval=ymin, maxval=ymax, pad=0)
|
||||
inset.set_xlim(0, pdf.max())
|
||||
inset.axis('off')
|
||||
return None
|
||||
|
||||
|
||||
# GENERAL SETTINGS:
|
||||
with_noise = True
|
||||
with_noise = False
|
||||
target = 'Omocestus_rufipes'
|
||||
search_kwargs = dict(
|
||||
incl='subset' if not with_noise else 'subset_noise',
|
||||
incl=['subset', 'noise'] if with_noise else 'subset',
|
||||
excl=None if with_noise else 'noise',
|
||||
dir='../data/inv/thresh_lp/'
|
||||
)
|
||||
data_paths = search_files(target, **search_kwargs)
|
||||
@@ -59,9 +65,9 @@ load_kwargs = dict(
|
||||
files=stages,
|
||||
keywords=['scales', 'snip', 'measure', 'thresh']
|
||||
)
|
||||
save_path = None#'../figures/fig_invariance_thresh_lp_single'
|
||||
save_path = '../figures/fig_invariance_thresh_lp_single.pdf'
|
||||
if with_noise and save_path is not None:
|
||||
save_path += '_noise'
|
||||
save_path = save_path.replace('.pdf', '_noise.pdf')
|
||||
|
||||
# GRAPH SETTINGS:
|
||||
fig_kwargs = dict(
|
||||
@@ -69,7 +75,7 @@ fig_kwargs = dict(
|
||||
)
|
||||
super_grid_kwargs = dict(
|
||||
nrows=None,
|
||||
ncols=2,
|
||||
ncols=3,
|
||||
wspace=0,
|
||||
hspace=0,
|
||||
left=0,
|
||||
@@ -77,14 +83,18 @@ super_grid_kwargs = dict(
|
||||
bottom=0,
|
||||
top=1
|
||||
)
|
||||
subfig_specs = dict(
|
||||
snip=(slice(None), slice(super_grid_kwargs['ncols'] - 1)),
|
||||
big=(slice(None), -1),
|
||||
)
|
||||
snip_grid_kwargs = dict(
|
||||
nrows=len(stages),
|
||||
ncols=None,
|
||||
wspace=0.11,
|
||||
wspace=0.3,
|
||||
hspace=0.1,
|
||||
left=0.1,
|
||||
right=0.95,
|
||||
bottom=0.01,
|
||||
right=0.93,
|
||||
bottom=0.05,
|
||||
top=0.85
|
||||
)
|
||||
big_grid_kwargs = dict(
|
||||
@@ -92,20 +102,22 @@ big_grid_kwargs = dict(
|
||||
ncols=1,
|
||||
wspace=0,
|
||||
hspace=0,
|
||||
left=0.15,
|
||||
left=0.17,
|
||||
right=0.96,
|
||||
bottom=0.1,
|
||||
top=0.99
|
||||
)
|
||||
inset_bounds = [1, 0, 0.1, 1]
|
||||
inset_bounds = [1.02, 0, 0.2, 1]
|
||||
|
||||
# PLOT SETTINGS:
|
||||
colors = load_colors('../data/stage_colors.npz')
|
||||
# lw_snippets = dict(
|
||||
# conv=0.5,
|
||||
# feat=2
|
||||
# )
|
||||
# lw_analysis = 3
|
||||
color_factors = [0.2, -0.2]
|
||||
lw = dict(
|
||||
conv=1,
|
||||
bi=0.1,
|
||||
feat=3,
|
||||
big=4,
|
||||
)
|
||||
xlabels = dict(
|
||||
big='scale $\\alpha$',
|
||||
)
|
||||
@@ -135,42 +147,49 @@ ylab_super_kwargs = dict(
|
||||
va='center',
|
||||
)
|
||||
ylab_big_kwargs = dict(
|
||||
x=0.02,
|
||||
x=0,
|
||||
fontsize=20,
|
||||
ha='center',
|
||||
va='top',
|
||||
)
|
||||
# xloc = dict(
|
||||
# analysis=10,
|
||||
# )
|
||||
# letter_snip_kwargs = dict(
|
||||
# x=0.02,
|
||||
# y=1,
|
||||
# ha='left',
|
||||
# va='top',
|
||||
# fontsize=22,
|
||||
# fontweight='bold'
|
||||
# )
|
||||
# letter_analysis_kwargs = dict(
|
||||
# x=0,
|
||||
# y=1,
|
||||
# ha='left',
|
||||
# va='top',
|
||||
# fontsize=22,
|
||||
# fontweight='bold'
|
||||
# )
|
||||
# bar_time = 5
|
||||
# bar_kwargs = dict(
|
||||
# y0=0.7,
|
||||
# y1=0.8,
|
||||
# color='k',
|
||||
# lw=0,
|
||||
# )
|
||||
yloc = dict(
|
||||
big=0.2,
|
||||
)
|
||||
letter_snip_kwargs = dict(
|
||||
x=0.01,
|
||||
y=0.9,
|
||||
ha='left',
|
||||
va='top',
|
||||
fontsize=22,
|
||||
)
|
||||
letter_big_kwargs = dict(
|
||||
x=0,
|
||||
yref=letter_snip_kwargs['y'],
|
||||
ha='left',
|
||||
va='top',
|
||||
fontsize=22,
|
||||
)
|
||||
dist_kwargs = dict(
|
||||
nbins=50,
|
||||
c='k',
|
||||
lw=1,
|
||||
)
|
||||
dist_fill_kwargs = dict(
|
||||
color=colors['bi'],
|
||||
lw=0.1,
|
||||
)
|
||||
bar_time = 0.5
|
||||
bar_kwargs = dict(
|
||||
y0=0.3,
|
||||
y1=0.4,
|
||||
color='k',
|
||||
lw=0,
|
||||
)
|
||||
kernel = np.array([
|
||||
[2, 0.008],
|
||||
[4, 0.008],
|
||||
])[:1]
|
||||
zoom_rel = np.array([0.5, 0.55])
|
||||
zoom_rel = np.array([0.5, 0.525])
|
||||
|
||||
|
||||
# EXECUTION:
|
||||
@@ -193,6 +212,14 @@ for data_path in data_paths:
|
||||
data['threshs'] = data['threshs'][:, kern_ind]
|
||||
t_full = np.arange(data['snip_conv'].shape[0]) / config['env_rate']
|
||||
|
||||
# Get threshold-specific colors:
|
||||
factors = np.linspace(*color_factors, data['thresh_perc'].size)
|
||||
colors = dict(
|
||||
conv=shade_colors(colors['conv'], factors),
|
||||
bi=shade_colors(colors['bi'], factors),
|
||||
feat=shade_colors(colors['feat'], factors),
|
||||
)
|
||||
|
||||
# Adjust grid parameters:
|
||||
super_grid_kwargs['nrows'] = data['thresh_perc'].size
|
||||
snip_grid_kwargs['ncols'] = data['example_scales'].size
|
||||
@@ -201,22 +228,11 @@ for data_path in data_paths:
|
||||
fig = plt.figure(**fig_kwargs)
|
||||
super_grid = fig.add_gridspec(**super_grid_kwargs)
|
||||
|
||||
# Prepare analysis axis:
|
||||
big_subfig = fig.add_subfigure(super_grid[slice(None), 1])
|
||||
big_grid = big_subfig.add_gridspec(**big_grid_kwargs)
|
||||
big_ax = big_subfig.add_subplot(big_grid[0, 0])
|
||||
xlabel(big_ax, xlabels['big'], **xlab_big_kwargs,
|
||||
transform=big_subfig.transSubfigure)
|
||||
ylabel(big_ax, ylabels['big'], **ylab_big_kwargs,
|
||||
transform=big_subfig.transSubfigure)
|
||||
big_ax.set_xlim(data['scales'].min(), data['scales'].max())
|
||||
ylimits(data['measure_feat'], big_ax, minval=0, pad=0.05)
|
||||
big_ax.set_xscale('symlog', linthresh=data['scales'][1], linscale=0.5)
|
||||
|
||||
# Prepare snippet axes:
|
||||
snip_axes = {}
|
||||
for i in range(data['thresh_perc'].size):
|
||||
snip_subfig = fig.add_subfigure(super_grid[i, 0])
|
||||
subfig_specs['snip'] = (i, subfig_specs['snip'][1])
|
||||
snip_subfig = fig.add_subfigure(super_grid[subfig_specs['snip']])
|
||||
axes = add_snip_axes(snip_subfig, snip_grid_kwargs)
|
||||
snip_axes[snip_subfig] = axes
|
||||
super_ylabel(f'{data["thresh_perc"][i]}%', snip_subfig,
|
||||
@@ -225,95 +241,50 @@ for data_path in data_paths:
|
||||
ylabel(ax, ylabels[stage], **ylab_snip_kwargs,
|
||||
transform=snip_subfig.transSubfigure)
|
||||
if i == 0:
|
||||
time_bar(axes[0, 0], bar_time, **bar_kwargs)
|
||||
for ax, scale in zip(axes[0, :], data['example_scales']):
|
||||
ax.set_title(f'$\\alpha={strip_zeros(scale)}$')
|
||||
letter_subplots(snip_axes.keys(), **letter_snip_kwargs)
|
||||
|
||||
# Prepare analysis axis:
|
||||
big_subfig = fig.add_subfigure(super_grid[subfig_specs['big']])
|
||||
big_grid = big_subfig.add_gridspec(**big_grid_kwargs)
|
||||
big_ax = big_subfig.add_subplot(big_grid[0, 0])
|
||||
xlabel(big_ax, xlabels['big'], **xlab_big_kwargs,
|
||||
transform=big_subfig.transSubfigure)
|
||||
ylabel(big_ax, ylabels['big'], **ylab_big_kwargs,
|
||||
transform=big_subfig.transSubfigure)
|
||||
big_ax.set_xlim(data['scales'].min(), data['scales'].max())
|
||||
big_ax.set_xscale('symlog', linthresh=data['scales'][1], linscale=0.5)
|
||||
ylimits(data['measure_feat'], big_ax, minval=0, pad=0.01)
|
||||
big_ax.yaxis.set_major_locator(plt.MultipleLocator(yloc['big']))
|
||||
letter_subplot(big_subfig, 'd', **letter_big_kwargs, ref=list(snip_axes.keys())[0])
|
||||
|
||||
# Plot representation snippets per threshold:
|
||||
conv_min, conv_max = ylimits(data['snip_conv'], pad=0.02)
|
||||
for i, (subfig, axes) in enumerate(snip_axes.items()):
|
||||
dist_fill_kwargs['color'] = colors['bi'][i]
|
||||
|
||||
# Plot kernel response snippets:
|
||||
plot_snippets(axes[0, :], t_full, data['snip_conv'][:, :, i],
|
||||
c=colors['conv'], lw=0.5)
|
||||
thresh=data['threshs'][i], ymin=conv_min, ymax=conv_max,
|
||||
fill_kwargs=dist_fill_kwargs, c=colors['conv'][i], lw=lw['conv'])
|
||||
|
||||
# Plot binary snippets:
|
||||
plot_bi_snippets(axes[1, :], t_full, data['snip_bi'][:, :, i],
|
||||
color=colors['bi'], lw=0)
|
||||
color=colors['bi'][i], lw=lw['bi'])
|
||||
# Plot feature snippets:
|
||||
plot_snippets(axes[2, :], t_full, data['snip_feat'][:, :, i],
|
||||
ymin=0, ymax=1, c=colors['feat'], lw=2)
|
||||
ymin=0, ymax=1, c=colors['feat'][i], lw=lw['feat'])
|
||||
|
||||
# Plot kernel response distribution:
|
||||
side_distributions(axes[0, :], data['snip_conv'][:, :, i],
|
||||
inset_bounds, data['threshs'][i])
|
||||
side_distributions(axes[0, :], data['snip_conv'][:, :, i], inset_bounds,
|
||||
data['threshs'][i], ymin=conv_min, ymax=conv_max,
|
||||
fill_kwargs=dist_fill_kwargs, **dist_kwargs)
|
||||
|
||||
# Plot analysis results:
|
||||
big_ax.plot(data['scales'], data['measure_feat'],
|
||||
c=colors['feat'], lw=3)
|
||||
|
||||
|
||||
# # Prepare pure-song snippet axes:
|
||||
# pure_subfig = fig.add_subfigure(super_grid[subfig_specs['pure']])
|
||||
# pure_grid_kwargs['nrows' if pure_grid_kwargs['nrows'] is None else 'ncols'] = pure_data['example_scales'].size
|
||||
# pure_axes = add_snip_axes(pure_subfig, pure_grid_kwargs)
|
||||
# for ax, stage in zip(pure_axes[:, 0], stages):
|
||||
# ylabel(ax, ylabels[stage], **ylab_snip_kwargs,
|
||||
# transform=pure_subfig.transSubfigure)
|
||||
# for ax, scale in zip(pure_axes[snip_specs['conv']], pure_data['example_scales']):
|
||||
# ax.set_title(f'$\\alpha={strip_zeros(scale)}$')
|
||||
# pure_subfig.text(s='a', **letter_snip_kwargs)
|
||||
|
||||
# # Prepare analysis axis:
|
||||
# analysis_subfig = fig.add_subfigure(super_grid[subfig_specs['analysis']])
|
||||
# analysis_grid = analysis_subfig.add_gridspec(**analysis_grid_kwargs)
|
||||
# analysis_ax = analysis_subfig.add_subplot(analysis_grid[0, 0])
|
||||
# analysis_ax.set_xlim(noise_data['scales'].min(), noise_data['scales'].max())
|
||||
# analysis_ax.xaxis.set_major_locator(plt.MultipleLocator(xloc['analysis']))
|
||||
# xlabel(analysis_ax, xlabels['analysis'], **xlab_analysis_kwargs,
|
||||
# transform=analysis_subfig.transSubfigure)
|
||||
# # analysis_ax.set_yscale('log')
|
||||
# ylabel(analysis_ax, ylabels['analysis'], **ylab_analysis_kwargs,
|
||||
# transform=analysis_subfig.transSubfigure)
|
||||
# analysis_subfig.text(s='c', **letter_analysis_kwargs)
|
||||
|
||||
# # Plot pure-song kernel response snippets:
|
||||
# plot_snippets(pure_axes[snip_specs['conv']], t_full, pure_data['conv'],
|
||||
# c=colors['conv'], lw=lw_snippets['conv'])
|
||||
|
||||
# # Plot pure-song binary snippets:
|
||||
# plot_bi_snippets(pure_axes[snip_specs['bi']], t_full, pure_data['bi'],
|
||||
# color=colors['bi'], lw=0)
|
||||
|
||||
# # Plot pure-song feature snippets:
|
||||
# plot_snippets(pure_axes[snip_specs['feat']], t_full, pure_data['feat'],
|
||||
# ymin=0, ymax=1, c=colors['feat'], lw=lw_snippets['feat'])
|
||||
|
||||
# # Indicate time scale:
|
||||
# time_bar(pure_axes[snip_specs['conv']][0], bar_time, **bar_kwargs)
|
||||
|
||||
# # Plot noise-song kernel response snippets:
|
||||
# plot_snippets(noise_axes[snip_specs['conv']], t_full, noise_data['conv'],
|
||||
# c=colors['conv'], lw=lw_snippets['conv'])
|
||||
|
||||
# # Plot noise-song binary snippets:
|
||||
# plot_bi_snippets(noise_axes[snip_specs['bi']], t_full, noise_data['bi'],
|
||||
# color=colors['bi'], lw=0)
|
||||
|
||||
# # Plot noise-song feature snippets:
|
||||
# plot_snippets(noise_axes[snip_specs['feat']], t_full, noise_data['feat'],
|
||||
# ymin=0, ymax=1, c=colors['feat'], lw=lw_snippets['feat'])
|
||||
|
||||
# # Indicate time scale:
|
||||
# time_bar(noise_axes[snip_specs['conv']][0], bar_time, **bar_kwargs)
|
||||
|
||||
# # Plot noise-song SD ratios (limited):
|
||||
# analysis_ax.plot(noise_data['scales'], noise_data['measure_conv'],
|
||||
# c=colors['conv'], lw=lw_analysis)
|
||||
# lower, upper = noise_data['spread_conv']
|
||||
# analysis_ax.fill_between(noise_data['scales'], lower, upper,
|
||||
# color=colors['conv'], **spread_kwargs)
|
||||
# analysis_ax.plot(noise_data['scales'], noise_data['measure_feat'],
|
||||
# c=colors['feat'], lw=lw_analysis)
|
||||
# lower, upper = noise_data['spread_feat']
|
||||
# analysis_ax.fill_between(noise_data['scales'], lower, upper,
|
||||
# color=colors['feat'], **spread_kwargs)
|
||||
handles = big_ax.plot(data['scales'], data['measure_feat'], lw=lw['big'])
|
||||
[h.set_color(c) for h, c in zip(handles, colors['feat'])]
|
||||
|
||||
if save_path is not None:
|
||||
fig.savefig(save_path)
|
||||
|
||||
@@ -31,13 +31,27 @@ def hide_axis(ax, side='bottom'):
|
||||
which='both', **params)
|
||||
return None
|
||||
|
||||
def letter_subplots(axes, labels=None, x=0.02, y=1, ha='left', va='bottom',
|
||||
fontsize=16, fontweight='bold', **kwargs):
|
||||
def letter_subplot(artist, label, x=None, y=None, xref=None, yref=None, ref=None,
|
||||
ha='left', va='bottom', fontsize=16, fontweight='bold', **kwargs):
|
||||
trans_artist = BboxTransformTo(artist.bbox)
|
||||
if x is None or y is None:
|
||||
trans_ref = BboxTransformTo(ref.bbox)
|
||||
transform = trans_ref + trans_artist.inverted()
|
||||
if x is None:
|
||||
x = transform.transform([xref, 0])[0]
|
||||
if y is None:
|
||||
y = transform.transform([0, yref])[1]
|
||||
artist.text(x, y, label, transform=trans_artist, ha=ha, va=va,
|
||||
fontsize=fontsize, fontweight=fontweight, **kwargs)
|
||||
return None
|
||||
|
||||
def letter_subplots(artists, labels=None, x=None, y=None, xref=None, yref=None, ref=None,
|
||||
ha='left', va='bottom', fontsize=16, fontweight='bold', **kwargs):
|
||||
if labels is None:
|
||||
labels = string.ascii_lowercase
|
||||
for ax, label in zip(axes, labels):
|
||||
ax.text(x, y, label, transform=ax.transAxes, ha=ha, va=va,
|
||||
fontsize=fontsize, fontweight=fontweight, **kwargs)
|
||||
for artist, label in zip(artists, labels):
|
||||
letter_subplot(artist, label, x, y, xref, yref, ref=ref, ha=ha, va=va,
|
||||
fontsize=fontsize, fontweight=fontweight, **kwargs)
|
||||
return None
|
||||
|
||||
def xlimits(time, ax=None, minval=None, maxval=None, pad=0.05):
|
||||
|
||||
Reference in New Issue
Block a user