The objective is to create subplot that consist
- Line plot
- raw data plot with annotation
The expected output is as shown the figure below
The line plot can be easily created by simply passing the axes parameter
import matplotlib.pyplot as plt
fig = plt.figure(figsize=(9, 10))
ax1 = fig.add_subplot(2, 1, 1)
ax1.plot(range(10))
However, I am having difficulties in subploting the row plot since mne.io.Raw.plot
does not accept axes
import os
import mne
sample_data_folder = mne.datasets.sample.data_path()
sample_data_raw_file = os.path.join(sample_data_folder, 'MEG', 'sample',
'sample_audvis_raw.fif')
raw = mne.io.read_raw_fif(sample_data_raw_file, verbose=False)
picks = mne.pick_channels_regexp(raw.ch_names, regexp='EEG 05.')
fig=raw.plot(order=picks, n_channels=len(picks))
While it is possible to first save locally fig.savefig()
and append the raw.plot into the subplot as below
sub1 = fig.add_subplot(2, 1, 2)
image2 = cv.imread()
sub1.imshow(image2, 'gray')
But, this is inefficient for multiple plotting.
So, my question is, is there better workaround to append the raw.plot onto a subplot without first need to save locally the fig?