Again, numerous changes.
Mostly figure polishing and fixing. Crucial fix to "short" invariance analysis.
This commit is contained in:
@@ -39,17 +39,20 @@ 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, nbins=1000,
|
||||
fill_kwargs={}, **kwargs):
|
||||
limits = np.array([snippets.min(), snippets.max()]) * 1.1
|
||||
def side_distributions(axes, snippets, inset_bounds, thresh, nbins=50,
|
||||
limits=None, fill_kwargs={}, **kwargs):
|
||||
if limits is None:
|
||||
limits = np.array([snippets.min(), snippets.max()]) * 1.1
|
||||
edges = np.linspace(*limits, nbins + 1)
|
||||
centers = edges[:-1] + (edges[1] - edges[0]) / 2
|
||||
insets = []
|
||||
for ax, snippet in zip(axes, snippets.T):
|
||||
pdf, _ = np.histogram(snippet, edges, density=True)
|
||||
inset = ax.inset_axes(inset_bounds)
|
||||
inset.plot(pdf, centers, **kwargs)
|
||||
inset.fill_betweenx(centers, pdf.min(), pdf, where=(centers > thresh), **fill_kwargs)
|
||||
handle = inset.plot(pdf, centers, **kwargs)[0]
|
||||
set_clip_box(handle, inset, bounds=[[-0.05, 0], [1.05, 1]])
|
||||
handle = inset.fill_betweenx(centers, pdf.min(), pdf, where=(centers > thresh), **fill_kwargs)
|
||||
set_clip_box(handle, inset, bounds=[[-0.05, 0], [1.05, 1]])
|
||||
inset.set_xlim(0, pdf.max())
|
||||
inset.set_ylim(ax.get_ylim())
|
||||
inset.axis('off')
|
||||
@@ -99,7 +102,7 @@ snip_grid_kwargs = dict(
|
||||
right=0.93,
|
||||
bottom=0.15,
|
||||
top=0.95,
|
||||
height_ratios=[2, 1, 1]
|
||||
height_ratios=[4, 1, 2]
|
||||
)
|
||||
input_grid_kwargs = dict(
|
||||
nrows=1,
|
||||
@@ -115,10 +118,10 @@ big_grid_kwargs = dict(
|
||||
nrows=2,
|
||||
ncols=1,
|
||||
wspace=0,
|
||||
hspace=0.3,
|
||||
hspace=0.15,
|
||||
left=0.17,
|
||||
right=0.96,
|
||||
bottom=0.1,
|
||||
bottom=0.05,
|
||||
top=0.99
|
||||
)
|
||||
dist_inset_bounds = [1.02, 0, 0.2, 1]
|
||||
@@ -140,6 +143,7 @@ lw = dict(
|
||||
bi=0.1,
|
||||
feat=3,
|
||||
big=4,
|
||||
thresh=1.5,
|
||||
kern=2.5,
|
||||
plateau=1.5,
|
||||
)
|
||||
@@ -155,16 +159,16 @@ ylabels = dict(
|
||||
big='$\\mu_f$',
|
||||
)
|
||||
xlab_alpha_kwargs = dict(
|
||||
y=-0.15,
|
||||
y=0.5,
|
||||
fontsize=fs['lab_norm'],
|
||||
ha='center',
|
||||
va='top',
|
||||
va='bottom',
|
||||
)
|
||||
xlab_sigma_kwargs = dict(
|
||||
y=-0.12,
|
||||
y=0,
|
||||
fontsize=fs['lab_tex'],
|
||||
ha=xlab_alpha_kwargs['ha'],
|
||||
va=xlab_alpha_kwargs['va'],
|
||||
va='bottom',
|
||||
)
|
||||
ylab_snip_kwargs = dict(
|
||||
x=0.08,
|
||||
@@ -212,8 +216,8 @@ letter_snip_kwargs = dict(
|
||||
fontsize=fs['letter'],
|
||||
)
|
||||
letter_big_kwargs = dict(
|
||||
x=0,
|
||||
yref=letter_snip_kwargs['y'],
|
||||
xref=0,
|
||||
y=1,
|
||||
ha='left',
|
||||
va='top',
|
||||
fontsize=fs['letter'],
|
||||
@@ -230,6 +234,12 @@ dist_fill_kwargs = dict(
|
||||
color=colors['bi'],
|
||||
lw=0.1,
|
||||
)
|
||||
thresh_kwargs = dict(
|
||||
color='k',
|
||||
lw=lw['thresh'],
|
||||
ls='--',
|
||||
zorder=3,
|
||||
)
|
||||
bar_time = 0.1
|
||||
bar_kwargs = dict(
|
||||
dur=bar_time,
|
||||
@@ -353,9 +363,11 @@ for i in range(thresh_rel.size):
|
||||
subfig_spec[0] = slice(*(subfig_spec[0] + i * snip_rows))
|
||||
snip_subfig = fig.add_subfigure(super_grid[*subfig_spec])
|
||||
axes = add_snip_axes(snip_subfig, snip_grid_kwargs)
|
||||
low_box = axes[-1, 0].get_position()
|
||||
high_box = axes[0, 0].get_position()
|
||||
[hide_axis(ax, 'left') for ax in axes[1:, 1]]
|
||||
super_ylabel(f'$\\Theta={strip_zeros(thresh_rel[i])}\\cdot\\sigma_{{\\eta}}$',
|
||||
snip_subfig, axes[-1, 0], axes[0, 0], **ylab_super_kwargs)
|
||||
snip_subfig, axes[-1, 0], axes[0, 0], **ylab_super_kwargs)
|
||||
for (ax1, ax2), stage in zip(axes[:, :2], stages):
|
||||
ax1.yaxis.set_major_locator(plt.MultipleLocator(yloc[stage][0]))
|
||||
ax2.yaxis.set_major_locator(plt.MultipleLocator(yloc[stage][1]))
|
||||
@@ -376,17 +388,18 @@ alpha_ax.set_xlim(scales[0], scales[-1])
|
||||
alpha_ax.set_xscale('symlog', linthresh=scales[scales > 0][0], linscale=0.5)
|
||||
ylimits(pure_data['measure_feat'], alpha_ax, minval=0, pad=ypad['big'])
|
||||
alpha_ax.yaxis.set_major_locator(plt.MultipleLocator(yloc['big']))
|
||||
xlabel(alpha_ax, xlabels['alpha'], **xlab_alpha_kwargs)
|
||||
xlabel(alpha_ax, xlabels['alpha'], **xlab_alpha_kwargs, transform=big_subfig)
|
||||
ylabel(alpha_ax, ylabels['big'], transform=big_subfig.transSubfigure, **ylab_big_kwargs)
|
||||
letter_subplot(alpha_ax, 'e', ref=big_subfig, **letter_big_kwargs)
|
||||
|
||||
sigma_ax = big_subfig.add_subplot(big_grid[1, 0])
|
||||
sigma_ax.set_xlim(noise_data['measure_inv'].min(), noise_data['measure_inv'].max())
|
||||
sigma_ax.set_xlim(scales[0], scales[-1])
|
||||
sigma_ax.set_xlim(1, noise_data['measure_inv'].max())
|
||||
sigma_ax.set_xscale('symlog', linthresh=scales[scales > 0][0], linscale=0.5)
|
||||
ylimits(pure_data['measure_feat'], sigma_ax, minval=0, pad=ypad['big'])
|
||||
sigma_ax.yaxis.set_major_locator(plt.MultipleLocator(yloc['big']))
|
||||
xlabel(sigma_ax, xlabels['sigma'], **xlab_sigma_kwargs)
|
||||
xlabel(sigma_ax, xlabels['sigma'], **xlab_sigma_kwargs, transform=big_subfig)
|
||||
ylabel(sigma_ax, ylabels['big'], transform=big_subfig.transSubfigure, **ylab_big_kwargs)
|
||||
letter_subplot(sigma_ax, 'f', ref=big_subfig, **letter_big_kwargs)
|
||||
|
||||
# Plot intensity-adapted snippets:
|
||||
plot_snippets(input_axes, t_full, noise_data['snip_inv'],
|
||||
@@ -403,13 +416,18 @@ for i, (subfig, axes) in enumerate(zip(snip_subfigs, snip_axes)):
|
||||
# Plot kernel response snippets:
|
||||
plot_snippets(axes[0, :], t_full, noise_data['snip_conv'], thresh=thresh_abs[i],
|
||||
ypad=ypad['conv'], fill_kwargs=dist_fill_kwargs, c=shaded['conv'][i], lw=lw['conv'])
|
||||
ylimits(noise_data['snip_conv'][:, 0], axes[0, 0], pad=ypad['conv'])
|
||||
ylim_zoom = ylimits(noise_data['snip_conv'][:, 0], axes[0, 0],
|
||||
pad=ypad['conv'], maxval=thresh_abs[-1])
|
||||
|
||||
# Indicate absolute threshold value:
|
||||
handle = axes[0, 0].axhline(thresh_abs[i], **thresh_kwargs)
|
||||
set_clip_box(handle, axes[0, 0], bounds=[[0, 0], [1, 1.05]])
|
||||
|
||||
# Plot kernel response distributions:
|
||||
side_distributions(axes[0, :1], noise_data['snip_conv'][:, :1], dist_inset_bounds,
|
||||
thresh_abs[i], nbins=50, fill_kwargs=dist_fill_kwargs, **dist_kwargs)
|
||||
thresh_abs[i], nbins=50, limits=ylim_zoom, fill_kwargs=dist_fill_kwargs, **dist_kwargs)
|
||||
side_distributions(axes[0, 1:], noise_data['snip_conv'][:, 1:], dist_inset_bounds,
|
||||
thresh_abs[i], nbins=50, fill_kwargs=dist_fill_kwargs, **dist_kwargs)
|
||||
thresh_abs[i], nbins=50, fill_kwargs=dist_fill_kwargs, **dist_kwargs)
|
||||
|
||||
# Plot binary snippets:
|
||||
plot_bi_snippets(axes[1, :], t_full, noise_data['snip_bi'][:, :, i],
|
||||
@@ -444,7 +462,7 @@ for ax, x in zip([alpha_ax, sigma_ax], [scales, noise_data['measure_inv']]):
|
||||
ax.plot(x[ind], 0, mfc=color, mec='k', alpha=0.75, zorder=6,
|
||||
**plateau_dot_kwargs, transform=ax.get_xaxis_transform())
|
||||
ax.vlines(x[ind], ax.get_ylim()[0], noise_data['measure_feat'][ind, i],
|
||||
color=color, **plateau_line_kwargs)
|
||||
color=color, **plateau_line_kwargs)
|
||||
|
||||
# Add proxy legend:
|
||||
if ax == alpha_ax:
|
||||
|
||||
Reference in New Issue
Block a user