Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
topoplot eeg
#1
Lightbulb 
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)
Yoriz write Dec-23-2022, 01:09 PM:
Please post all code, output and errors (in their entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Reply
#2
Without digging in too deeply, I'd refer you to the docs regarding heatmaps in matplotlib. Includes examples
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020