TFR-Plot: How to scale x and y-axis

Hello everyone,

I have a question regarding the sizing of x and y-axis in my plot

grandAvg.plot(['P7', 'P3', 'Pz', 'P4', 'P8'],title='Memory comparison (Parietal electrodes)',
              tmin=-1, tmax=3, show=True, vmin=-0.04, vmax=0.04, cmap='viridis')

I get a nice plot


But to be able to add it into a paper, I have to reduce the size of the plot a lot, which makes the x and y-axis way too small to be readable.
I am not sure how to solve this problem.
Thank you for your help

Best, a confused PhD-student

That’s just a matplotlib figure, so you just to need set some property using matplotlib.pyplot like plt.xlim()

I tried different codes but it doesnt work unfortunatly

gandAvg.plot(['Oz','O1'],title='CS+ comparison (O1, Oz)',
                        tmin=-1, tmax=4, show=True, vmin=-0.05, vmax=0.05, cmap='viridis')

plt.set_xlabel(axis='Time', frontsize=14)

What do you mean by reduce the size of the plot

I believe they want to make the dimensions of the plot smaller, but labels should still be readable.

Does this mean the DPI of the figure is a little big?
I think just save the figure locally and resize the figure in the editor like Word

Yes exactly! If I reduce the size of the whole plot by e.g. paste it in a word document and make the plot fit into the document, labels get so small that they are unreadable. So I would need a code where e.g. I can set a front size for those labels


plt.xlabel('xaxis', fontsize = 16)
plt.ylabel('yaxis', fontsize = 20)

Thank you, this already helped! This made the title of x and y axis larger but the values on the axes itself are still small. Is it possible to enlarge also the values themself e.g plot above, time values -1.0, -0.5, 0.0, 0.5 … or respectively frequency values 5, 10, 15 …

try add

plt.xticks(fontsize = 20)
plt.yticks(fontsize = 20)

Hello @FranziMNE,

many journals specify the expected width (entire page or single-column) and resolution of the figures you need to submit.

You can use Matplotlib to create figures that exactly match these specifications, without too much manual fiddling.

For example, assuming you want to save a figure that’s 15 cm wide and has a resolution of 1200 dpi, you can use:

target_width_cm = 15
target_width_in = 15 / 2.54  # convert to inches


        'compression': 'tiff_lzw'  # drastically reduces file size

The resulting image will still have a bit of padding around it, which you can remove by doing something like:

        'compression': 'tiff_lzw'  # drastically reduces file size

However, in this case, the resulting width won’t exactly match 15 cm at 1200 dpi anymore, unfortunately.

Here’s a complete working example based on one of the MNE tutorials:

# %%
import os.path as op
import numpy as np

import mne
from mne.time_frequency import tfr_morlet, psd_multitaper, psd_welch
from mne.datasets import somato

data_path = somato.data_path()
subject = '01'
task = 'somato'
raw_fname = op.join(data_path, 'sub-{}'.format(subject), 'meg',
                    'sub-{}_task-{}_meg.fif'.format(subject, task))

raw =
raw.crop(120, 360).load_data().resample(200)
events = mne.find_events(raw, stim_channel='STI 014')

picks = mne.pick_types(, meg='grad', eeg=False, eog=True, stim=False)
event_id, tmin, tmax = 1, -1., 3.
baseline = (None, 0)
epochs = mne.Epochs(raw, events, event_id, tmin, tmax, picks=picks,
                    baseline=baseline, reject=dict(grad=4000e-13, eog=350e-6),

psds, freqs = psd_multitaper(epochs, fmin=2, fmax=40, n_jobs=1)
psds = 10 * np.log10(psds)  # convert to dB
psds_mean = psds.mean(0).mean(0)
psds_std = psds.mean(0).std(0)

freqs = np.logspace(*np.log10([6, 35]), num=8)
n_cycles = freqs / 2.  # different number of cycle per frequency
power, itc = tfr_morlet(
    epochs, freqs=freqs, n_cycles=n_cycles, use_fft=True,
    return_itc=True, decim=3, n_jobs=-1

# %%
figs = power.plot([82], baseline=(-0.5, 0), mode='logratio', title=power.ch_names[82])
fig = figs[0]

# %%
target_width_cm = 15
target_width_in = 15 / 2.54


# %%
    # bbox_inches='tight',
    # pad_inches=0,
        'compression': 'tiff_lzw'

I hope this helps you a bit!

Best wishes,


Thank you so much!! This works perfectly!!! :blush:

1 Like