If you have a question or issue with MNE-Python, please include the following info:
MNE version: 1.3.0
operating system: Windows 11
Please also provide relevant code snippets – ideally a minimal working example (MWE).
The following way definitely doesn’t works.
raw.compute_psd().plot(title=“rar”)
apparently the plot() fn returns a bool. Is there a way to easily add a title to the new compute_psd().plot() function?
You can pass in a matplotlib.Axes object to the plot method of the Spectrum class. Then, you can set a custom title (among other things).
The bottom half of the code below should be what you are looking for.
import matplotlib.pyplot as plt
import mne
from mne.datasets.sample import data_path
# Just grabbing a sample file
fname = data_path() / "MEG" /"sample" / "sample_audvis_filt-0-40_raw.fif"
raw = mne.io.read_raw_fif(fname, preload=True)
raw.pick("eeg")
psd = raw.compute_psd()
# This is the relevant part
axes = plt.subplot() # create your own axes object
fig = psd.plot(axes=axes, show=False)
fig.axes[0].set_title("My PSD Plot") # access the axes object and set the title
plt.show()