Files
paper_2025/python/fig_kernel_sd_perc_appendix.py
j-hartling 7e1aa8721a 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>
2026-04-27 18:18:34 +02:00

86 lines
1.6 KiB
Python

import plotstyle_plt
import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import norm
from plot_functions import xlabel, ylabel
from IPython import embed
# Analysis settings:
mode = ['thresh_lp', 'full', 'short', 'field'][3]
thresh_path = f'../data/inv/{mode}/thresholds.npz'
save_path = f'../figures/fig_kernel_sd_perc_{mode}_appendix.pdf'
# Plot settings:
fig_kwargs = dict(
figsize=(32/2.54, 16/2.54),
nrows=1,
ncols=1,
gridspec_kw=dict(
wspace=0,
hspace=0,
left=0.09,
right=0.99,
bottom=0.11,
top=0.98,
)
)
line_kwargs = dict(
c='black',
lw=1,
alpha=0.5,
)
fit_kwargs = dict(
c='red',
lw=3,
ls='--',
)
grid_line_kwargs = dict(
visible=True,
which='major',
axis='both',
color='k',
lw=0.5,
)
xlab = '$\\text{multiple of }\\sigma_{k_i}$'
ylab = '$P\\,(c_i > \\Theta_i)$'
xlab_kwargs = dict(
y=0,
fontsize=20,
ha='center',
va='bottom',
)
ylab_kwargs = dict(
x=0,
fontsize=20,
ha='center',
va='top',
)
# Load threshold data:
data = dict(np.load(thresh_path))
factors = data['factors']
perc = data['percs']
# Get Gaussian CDF for reference:
fit = norm.cdf(factors, loc=0, scale=1)[::-1]
# Prepare graph:
fig, ax = plt.subplots(**fig_kwargs)
ax.grid(**grid_line_kwargs)
ax.set_xlim(factors[0], factors[-1])
ax.set_ylim(-0.01, 1.01)
ylabel(ax, ylab, transform=fig.transFigure, **ylab_kwargs)
xlabel(ax, xlab, transform=fig.transFigure, **xlab_kwargs)
# Plotting:
ax.plot(factors, perc, **line_kwargs)
ax.plot(factors, fit, **fit_kwargs)
# Save figure:
fig.savefig(save_path)
plt.show()
print('Done.')