Python Forum

Full Version: topoplot eeg
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I want to plot heatmap eeg in the same distance divider, how can i do it?
for example, i want to plot data and data1 (below) in the same distance divider, please help me!
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1 import make_axes_locatable

from mne import create_info
from mne.viz import plot_topomap

data =[0.4696,0.14846,0.135,0.09,0.077,0.07,0.626,0.155,0.16353,0.29189,0.3039,0.255,0.726,0.65];
data2 =[0.176,0.07,0.06,0.04,0.04,0.03,0.3,0.08,0.09,0.12,0.14,0.13,0.28,0.25];

channels = ['AF3','F7','F3','FC5','T7','P7','O1','O2',
            'P8','T8','FC6', 'F4','F8',
            'AF4']

placeholder = np.random.random((25, 25))

# create info instance
info = create_info(ch_names=channels, sfreq=512, ch_types='eeg')
info.set_montage('standard_1005')


# figsize unit is inches
fig, axes = plt.subplots(nrows=2, ncols=1, figsize=(20, 10),
                         gridspec_kw=dict(height_ratios=[4, 3]))


axes[0].imshow(placeholder)
axes[0].axis('off')

im,_ = plot_topomap(data, info, axes=axes[1], show=False, cmap = 'coolwarm')
im,_ = plot_topomap(data2, info, axes=axes[1], show=False, cmap = 'coolwarm')


divider = make_axes_locatable(axes[1])
cax = divider.append_axes('right', size='2%', pad=0.2)
cbar = plt.colorbar(im, cax=cax)
Without digging in too deeply, I'd refer you to the docs regarding heatmaps in matplotlib. Includes examples