improved figures and captions

This commit is contained in:
2026-01-29 00:24:26 +01:00
parent 481f11368c
commit 195f419a90
3 changed files with 23 additions and 12 deletions

View File

@@ -239,10 +239,12 @@ def plot_rate(ax, s, spikes, tmin, tmax, sigma=0.002):
mask = (time >= tmin) & (time <= tmax)
time = time[mask] - tmin
r = r[mask]
ax.show_spines('')
ax.plot(1000*time, r, **s.lsRate)
ax.show_spines('l')
ax.plot(1000*time, r, clip_on=False, **s.lsRate)
ax.set_xlim(0, 1000*(tmax - tmin))
ax.set_ylim(-10, 550)
ax.set_ylim(0, 550)
ax.set_ylabel('Rate', 'Hz')
ax.set_yticks_delta(200)
def plot_psd(ax, s, freqs, power, fmax, dt=0.0005, nfft=512):
@@ -250,11 +252,13 @@ def plot_psd(ax, s, freqs, power, fmax, dt=0.0005, nfft=512):
mask = freqs <= fmax
freqs = freqs[mask]
power = power[mask]
ax.show_spines('b')
ax.show_spines('lb')
ax.plot(freqs, power, **s.lsPower)
ax.set_xlim(0, fmax)
ax.set_ylim(-20, 0)
ax.set_xlabel('Frequency', 'Hz')
ax.set_ylabel('Power', 'dB')
ax.set_yticks_delta(10)
def mark_freq(ax, freqs, power, f, label, style, xoffs=10, yoffs=0, toffs=0, angle=0):
@@ -286,7 +290,8 @@ if __name__ == '__main__':
s = plot_style()
fig, axs = plt.subplots(5, 4, cmsize=(s.plot_width, 0.6*s.plot_width),
height_ratios=[1, 0, 2, 1.3, 3, 0.7, 5])
fig.subplots_adjust(leftm=3, rightm=4.5, topm=1.5, bottomm=4, wspace=0.4, hspace=0.4)
fig.subplots_adjust(leftm=7.5, rightm=4.5, topm=1.5, bottomm=4,
wspace=0.4, hspace=0.4)
fmax = 250
tmin = 0.106
tmax = 0.206
@@ -318,11 +323,14 @@ if __name__ == '__main__':
mark_freq(axs[4, 3], freqs, powers[3], df1, '', s.psF0)
mark_freq(axs[4, 3], freqs, powers[3], df1, '', s.psF01, 130, 1.5)
mark_freq(axs[4, 3], freqs, powers[3], abs(df1) + abs(df2) - 2,
f'$\\Delta f_1 + \\Delta f_2={abs(df1) + abs(df2):.0f}$\\,Hz', s.psF012, 20, angle=40)
f'$\\Delta f_2 + \\Delta f_1={abs(df1) + abs(df2):.0f}$\\,Hz', s.psF012, 20, angle=40)
mark_freq(axs[4, 3], freqs, powers[3], abs(df1) - abs(df2),
f'$\\Delta f_1 + \\Delta f_2={abs(df1) - abs(df2):.0f}$\\,Hz', s.psF01_2, 50, toffs=5, angle=40)
axs[3, 0].scalebars(-0.03, 0, 20, 500, 'ms', 'Hz')
axs[4, 0].yscalebar(-0.03, 0.5, 10, 'dB', va='center')
f'$\\Delta f_2 - \\Delta f_1={abs(df1) - abs(df2):.0f}$\\,Hz', s.psF01_2, 50, toffs=5, angle=40)
fig.common_yticks(axs[3, :])
fig.common_yticks(axs[4, :])
axs[3, 0].xscalebar(1, 0, 20, 'ms', ha='right')
#axs[3, 0].scalebars(-0.03, 0, 20, 500, 'ms', 'Hz')
#axs[4, 0].yscalebar(-0.03, 0.5, 10, 'dB', va='center')
#fig.tag(axs.T)
fig.tag(axs[0])
fig.savefig()