Viz compare incomplete axis

Hi all! Im a trying to plot my evokeds. However, when using mne.viz.plot_compare_evokeds I get a incomplete x axis:

erp wrong

This is my code:

import matplotlib.pyplot as plt

fig, axes = plt.subplots(1)  # assuming 3 channel types
axes.set_xlim([-8,8])
axes.set_ylim([-6,6])
mne.viz.plot_compare_evokeds(dict(indoor = indoor_evoked, outdoor_natural = outdoor_natural_evoked, outdoor_manmade = outdoor_manmade_evoked),legend='upper right', show_sensors= False, ci=0.99, axes = axes)
fig.savefig('POZ_ERP_task_indep.png')

Hello,

You are setting the xlim and ylim first, and then you overwrite them by plotting on-top with plot_compare_evokeds. I suspect that you’ll get the correct output if you move the set_*lim after plot_compare_evokeds.

Mathieu

Hello Mathieu!
Thank you for your answer. I tried it but it did not work.

Ok, let’s try a couple of points:

  • first, can you tell us how long (in seconds) are each of the evoked?
  • second, what is your mne version?
  • third, let’s try without creating a figure beforehand and without changing the axis limits:
fig = mne.viz.plot_compare_evokeds(...)  # returns a list of figures
fig[0].savefig(...)

The function also has two parameters related to axis truncation, maybe check out these as well.

as @richard says, look at the parameters truncate_xaxis and truncate_yaxis in the plot_compare_evokeds function. That is what causes the axis truncation.

1 Like

@Evelyne_Fraats btw, the defaults will look much better with a recent version of MNE-Python. I think I changed these settings a short while ago; either the improvements are already included in MNE-Python 1.0, or will be in the very-soon-to-be-released 1.1.

1 Like