Skip to content

Instantly share code, notes, and snippets.

@ilkayisik
Last active July 3, 2019 14:33
Show Gist options
  • Save ilkayisik/d39732db89a12afb2f90c555061e80d1 to your computer and use it in GitHub Desktop.
Save ilkayisik/d39732db89a12afb2f90c555061e80d1 to your computer and use it in GitHub Desktop.
Use matplotlib to create subplots with time series plots using 2 for loops [here for subjects and movies]
import matplotlib.pyplot as plt
import seaborn as sns
for s in range(nr_subjects):
fig, ax = plt.subplots(5, 6, sharex=True, sharey=True, figsize=(15, 20))
sns.despine()
ax = ax.flatten()
for m in range(nr_movies):
ax[m].plot(cdt[s, m, :])
ax[m].plot(cdrt[s, m, :])
ax[m].set_ylim([-1.2, 1.2])
ax[m].text(10, -0.5, 'norm_lad: ' + "%.3f" %norm_lad_vals[s, m])
ax[m].text(10, -0.75, 'p r: ' + "%.3f" %pr_vals[s, m])
plt.suptitle('Participant: ' + '%.2d' %(s+1))
savename = 'ForSubject_' + '%.2d' %(s+1) + '.png'
plt.savefig(savename, dpi=300)
plt.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment