MNE Version 1.9.0, Windows 11;
Hello,
I would like to set a joint colorbar for the two different genders, but since they possess different maximum values and, respectively, different color encodings, how should i do that?
Thank You and best regards!
times = np.arange(-2.0, 13.0, 2.0)
topomap_args = dict(extrapolate="head")
cmap = cm.get_cmap()
all_conditions = [key for key in colors_compare_evokeds.keys() if key != 'Image Rating']
for gender, subjects in all_subject_epochs[1].items():
for subject, subject_epochs in subjects.items():
for condition in subject_epochs.event_id.keys():
condition_average = subject_epochs[condition].average()
topomap_subject_averages[gender][condition].append(condition_average)
for gender, conditions in topomap_subject_averages.items():
for condition, condition_epochs in conditions.items():
topomap_grand_averages_gender[gender][condition] = manual_average_epochs(condition_epochs)
for condition in all_conditions:
fig, axes = plt.subplots(
nrows=2,
ncols=9,
figsize=(12, 4),
gridspec_kw=dict(width_ratios=[1]*8 + [0.1])
)
evoked_female = topomap_grand_averages_gender['Female'][condition]
evoked_male = topomap_grand_averages_gender['Male'][condition]
all_evk = np.concatenate([evoked_male.data, evoked_female.data], axis=0)
cond_max = np.nanmax(all_evk)
vlim = (-cond_max, cond_max)
for i, gender in enumerate(['Female', 'Male']):
evoked = topomap_grand_averages_gender[gender][condition]
evoked.plot_topomap(
times=times,
axes=axes[i, :],
**topomap_args
)
axes[i, 0].set_ylabel(gender, fontsize=12, rotation=0, labelpad=40, va='center')
fig.savefig(f"{condition.replace(' / ', '_')}_topo", bbox_inches='tight', pad_inches=0, transparent=True)
plt.show()