# TFR plot

**URL:** <https://mne.discourse.group/t/tfr-plot/1360>\
**Category:** Mailing List Archive (read-only)\
**Tags:** list-archive\
**Created:** [November 9, 2017, 5:58pm UTC](https://mne.discourse.group/t/tfr-plot/1360 "2017-11-09T17:58:55Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [November 9, 2017, 5:58pm UTC](https://mne.discourse.group/t/tfr-plot/1360/1 "2017-11-09T17:58:55Z")

</div>

Hello all,

Do you know if it is possible to crop a tfr plot like in the attached  
picture to get rid of unwanted frequency bands. Thanks in advance.

Jeremy  
-------------- next part --------------  
An HTML attachment was scrubbed...  
URL: [http://mail.nmr.mgh.harvard.edu/pipermail/mne\_analysis/attachments/20171109/5134849d/attachment.html](http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20171109/5134849d/attachment.html)  
-------------- next part --------------  
A non-text attachment was scrubbed...  
Name: tfr.JPG  
Type: image/jpeg  
Size: 13251 bytes  
Desc: not available  
Url : [http://mail.nmr.mgh.harvard.edu/pipermail/mne\_analysis/attachments/20171109/5134849d/attachment.jpe](http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20171109/5134849d/attachment.jpe)

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [November 9, 2017, 8:07pm UTC](https://mne.discourse.group/t/tfr-plot/1360/2 "2017-11-09T20:07:40Z")

</div>

hi,

you can use pcolor eg  
[https://matplotlib.org/examples/pylab\_examples/pcolor\_demo.html](https://matplotlib.org/examples/pylab_examples/pcolor_demo.html)  
but a simpler option would be to put np.nan in values you don't want  
to plot and matplotlib  
with mask it.

HTH  
Alex

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [November 10, 2017, 8:23am UTC](https://mne.discourse.group/t/tfr-plot/1360/3 "2017-11-10T08:23:40Z")

</div>

thanks !

2017-11-09 21:07 GMT+01:00 Alexandre Gramfort \<alexandre.gramfort at inria.fr\>:

> hi,
> 
> you can use pcolor eg  
> [https://matplotlib.org/examples/pylab\_examples/pcolor\_demo.html](https://matplotlib.org/examples/pylab_examples/pcolor_demo.html)  
> but a simpler option would be to put np.nan in values you don't want  
> to plot and matplotlib  
> with mask it.
> 
> HTH  
> Alex
> 
> \> Hello all,  
> \>  
> \> Do you know if it is possible to crop a tfr plot like in the attached  
> \> picture to get rid of unwanted frequency bands. Thanks in advance.  
> \>  
> \> Jeremy  
> \>  
> \>  
> \> \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_  
> \> Mne\_analysis mailing list  
> \> Mne\_analysis at nmr.mgh.harvard.edu  
> \> [https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne\_analysis](https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis)  
> \>  
> \>  
> \> The information in this e-mail is intended only for the person to whom  
> it is  
> \> addressed. If you believe this e-mail was sent to you in error and the  
> \> e-mail  
> \> contains patient information, please contact the Partners Compliance  
> \> HelpLine at  
> \> [http://www.partners.org/complianceline](http://www.partners.org/complianceline) . If the e-mail was sent to you  
> in  
> \> error  
> \> but does not contain patient information, please contact the sender and  
> \> properly  
> \> dispose of the e-mail.  
> \>
> 
> \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_  
> Mne\_analysis mailing list  
> Mne\_analysis at nmr.mgh.harvard.edu  
> [https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne\_analysis](https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis)

-------------- next part --------------  
An HTML attachment was scrubbed...  
URL: [http://mail.nmr.mgh.harvard.edu/pipermail/mne\_analysis/attachments/20171110/e06a1fac/attachment-0001.html](http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20171110/e06a1fac/attachment-0001.html)

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [November 10, 2017, 2:37pm UTC](https://mne.discourse.group/t/tfr-plot/1360/4 "2017-11-10T14:37:47Z")

</div>

Yeah I usually do this by creating \*two\* separate pcolor plots, and then  
arranging the axes so that it \*looks\* like they're part of the same axis w/  
a break in the middle

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [November 10, 2017, 3:04pm UTC](https://mne.discourse.group/t/tfr-plot/1360/5 "2017-11-10T15:04:31Z")

</div>

If the aim is to clearly see low frequencies while ranging up to high  
frequencies, it is probably better to use a logarithmic frequency scale.

You can do this by simply changing the axis: e.g.

plt.gca().set\_yscale('log')

Better, you can do this when you compute the time frequency decomposition.  
For example in this tutorial (  
[https://martinos.org/mne/stable/auto\_examples/time\_frequency/plot\_time\_frequency\_simulated.html](https://martinos.org/mne/stable/auto_examples/time_frequency/plot_time_frequency_simulated.html)),  
change

freqs = np.arange  
\<[https://docs.scipy.org/doc/numpy-dev/reference/generated/numpy.arange.html#numpy.arange](https://docs.scipy.org/doc/numpy-dev/reference/generated/numpy.arange.html#numpy.arange)\>(5.,  
100., 3.)

by

freqs = np.l \<[https://docs.scipy.org/doc/numpy-dev/reference/generated/numpy.arange.html#numpy.arange](https://docs.scipy.org/doc/numpy-dev/reference/generated/numpy.arange.html#numpy.arange)\>ogspace(np.log10(5.),  
np.log10(100.), 32)

HTH  
JR

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [November 10, 2017, 4:29pm UTC](https://mne.discourse.group/t/tfr-plot/1360/6 "2017-11-10T16:29:45Z")

</div>

thank you !

2017-11-10 16:04 GMT+01:00 JR KING \<jeanremi.king at gmail.com\>:

> If the aim is to clearly see low frequencies while ranging up to high  
> frequencies, it is probably better to use a logarithmic frequency scale.
> 
> You can do this by simply changing the axis: e.g.
> 
> plt.gca().set\_yscale('log')
> 
> Better, you can do this when you compute the time frequency decomposition.  
> For example in this tutorial ([https://martinos.org/mne/](https://martinos.org/mne/)  
> stable/auto\_examples/time\_frequency/plot\_time\_frequency\_simulated.html),  
> change
> 
> freqs = np.arange \<[https://docs.scipy.org/doc/numpy-dev/reference/generated/numpy.arange.html#numpy.arange&gt;\](https://docs.scipy.org/doc/numpy-dev/reference/generated/numpy.arange.html#numpy.arange&gt;%5C)(5., 100., 3.)
> 
> by
> 
> freqs = np.l \<[https://docs.scipy.org/doc/numpy-dev/reference/generated/numpy.arange.html#numpy.arange&gt;ogspace\(np\.log10\(5\.\)](https://docs.scipy.org/doc/numpy-dev/reference/generated/numpy.arange.html#numpy.arange&gt;ogspace%5C(np%5C.log10%5C(5%5C.%5C)), np.log10(100.), 32)
> 
> HTH  
> JR
> 
> > Yeah I usually do this by creating \*two\* separate pcolor plots, and then  
> > arranging the axes so that it \*looks\* like they're part of the same axis w/  
> > a break in the middle  
> > --
> > 
> > > thanks !
> > > 
> > > 2017-11-09 21:07 GMT+01:00 Alexandre Gramfort \<  
> > > alexandre.gramfort at inria.fr\>:
> > > 
> > > > hi,
> > > > 
> > > > you can use pcolor eg  
> > > > [https://matplotlib.org/examples/pylab\_examples/pcolor\_demo.html](https://matplotlib.org/examples/pylab_examples/pcolor_demo.html)  
> > > > but a simpler option would be to put np.nan in values you don't want  
> > > > to plot and matplotlib  
> > > > with mask it.
> > > > 
> > > > HTH  
> > > > Alex
> > > > 
> > > > \> Hello all,  
> > > > \>  
> > > > \> Do you know if it is possible to crop a tfr plot like in the attached  
> > > > \> picture to get rid of unwanted frequency bands. Thanks in advance.  
> > > > \>  
> > > > \> Jeremy  
> > > > \>  
> > > > \>  
> > > > \> \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_  
> > > > \> Mne\_analysis mailing list  
> > > > \> Mne\_analysis at nmr.mgh.harvard.edu  
> > > > \> [https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne\_analysis](https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis)  
> > > > \>  
> > > > \>  
> > > > \> The information in this e-mail is intended only for the person to  
> > > > whom it is  
> > > > \> addressed. If you believe this e-mail was sent to you in error and the  
> > > > \> e-mail  
> > > > \> contains patient information, please contact the Partners Compliance  
> > > > \> HelpLine at  
> > > > \> [http://www.partners.org/complianceline](http://www.partners.org/complianceline) . If the e-mail was sent to  
> > > > you in  
> > > > \> error  
> > > > \> but does not contain patient information, please contact the sender  
> > > > and  
> > > > \> properly  
> > > > \> dispose of the e-mail.  
> > > > \>
> > > > 
> > > > \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_  
> > > > Mne\_analysis mailing list  
> > > > Mne\_analysis at nmr.mgh.harvard.edu  
> > > > [https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne\_analysis](https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis)
> > > 
> > > \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_  
> > > Mne\_analysis mailing list  
> > > Mne\_analysis at nmr.mgh.harvard.edu  
> > > [https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne\_analysis](https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis)
> > > 
> > > The information in this e-mail is intended only for the person to whom  
> > > it is  
> > > addressed. If you believe this e-mail was sent to you in error and the  
> > > e-mail  
> > > contains patient information, please contact the Partners Compliance  
> > > HelpLine at  
> > > [http://www.partners.org/complianceline](http://www.partners.org/complianceline) . If the e-mail was sent to you  
> > > in error  
> > > but does not contain patient information, please contact the sender and  
> > > properly  
> > > dispose of the e-mail.
> > 
> > \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_  
> > Mne\_analysis mailing list  
> > Mne\_analysis at nmr.mgh.harvard.edu  
> > [https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne\_analysis](https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis)
> > 
> > The information in this e-mail is intended only for the person to whom it  
> > is  
> > addressed. If you believe this e-mail was sent to you in error and the  
> > e-mail  
> > contains patient information, please contact the Partners Compliance  
> > HelpLine at  
> > [http://www.partners.org/complianceline](http://www.partners.org/complianceline) . If the e-mail was sent to you  
> > in error  
> > but does not contain patient information, please contact the sender and  
> > properly  
> > dispose of the e-mail.
> 
> \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_  
> Mne\_analysis mailing list  
> Mne\_analysis at nmr.mgh.harvard.edu  
> [https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne\_analysis](https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis)
> 
> The information in this e-mail is intended only for the person to whom it  
> is  
> addressed. If you believe this e-mail was sent to you in error and the  
> e-mail  
> contains patient information, please contact the Partners Compliance  
> HelpLine at  
> [http://www.partners.org/complianceline](http://www.partners.org/complianceline) . If the e-mail was sent to you in  
> error  
> but does not contain patient information, please contact the sender and  
> properly  
> dispose of the e-mail.

-------------- next part --------------  
An HTML attachment was scrubbed...  
URL: [http://mail.nmr.mgh.harvard.edu/pipermail/mne\_analysis/attachments/20171110/bf7d4c99/attachment.html](http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20171110/bf7d4c99/attachment.html)
