Files
paper_2025/python/fig_kernel_sd_perc_appendix.py
j-hartling 59a37503ba Captioned appendix figures.
Polished some figures.
Shortened existing figure captions.
2026-05-21 18:21:33 +02:00

90 lines
1.8 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'][0]
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, 15/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 = '$\\Theta_i\\,[\\text{multiples of }\\sigma_{c_i}]$'
ylab = '$\\mu_{f_i}\\,\\approx\\,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',
)
xloc = 1
yloc = 0.25
# 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)
ax.xaxis.set_major_locator(plt.MultipleLocator(xloc))
ax.yaxis.set_major_locator(plt.MultipleLocator(yloc))
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.')