<p><span style="padding: 3px 10px; border-radius: 5px; color: #ffffff; font-weight: bold; display: inline-block; background-color: #ff0000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;External Email - Use Caution&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></p><p></p><div dir="ltr"><div class="markdown-here-wrapper" style=""><p style="margin:0px 0px 1.2em!important">Hi Dillan,</p>
<p style="margin:0px 0px 1.2em!important">Did you try using the show parameter that is provided with <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline">plot_topomap</code> function? You should set it to <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline">False</code> so that <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline">plt.show()</code> is not called by MNE.</p>
<p style="margin:0px 0px 1.2em!important">The other option is to call <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline">matplotlib.use(&#39;Agg&#39;)</code> at the very top of your script before any imports. The only thing you can import before that is <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline">import matplotlib</code>.</p>
<p style="margin:0px 0px 1.2em!important">Hope that helps,<br>Mainak</p>
<div title="MDH:PGRpdj5IaSBEaWxsYW4sPC9kaXY+PGRpdj48YnI+PC9kaXY+PGRpdj5EaWQgeW91IHRyeSB1c2lu
ZyB0aGUgc2hvdyBwYXJhbWV0ZXIgdGhhdCBpcyBwcm92aWRlZCB3aXRoIGBwbG90X3RvcG9tYXBg
IGZ1bmN0aW9uLiBZb3Ugc2hvdWxkIHNldCBpdCB0byBgRmFsc2VgIHNvIHRoYXQgYHBsdC5zaG93
KClgIGlzIG5vdCBjYWxsZWQgYnkgTU5FLjwvZGl2PjxkaXY+PGJyPjwvZGl2PjxkaXY+VGhlIG90
aGVyIG9wdGlvbiBpcyB0byBjYWxsIGBtYXRwbG90bGliLnVzZSgnQWdnJylgIGF0IHRoZSB2ZXJ5
IHRvcCBvZiB5b3VyIHNjcmlwdCBiZWZvcmUgYW55IGltcG9ydHMuIFRoZSBvbmx5IHRoaW5nIHlv
dSBjYW4gaW1wb3J0IGJlZm9yZSB0aGF0IGlzIGBpbXBvcnQgbWF0cGxvdGxpYmAuPC9kaXY+PGRp
dj48YnI+PC9kaXY+PGRpdj5Ib3BlIHRoYXQgaGVscHMsPC9kaXY+PGRpdj5NYWluYWs8YnI+PC9k
aXY+" style="height:0;width:0;max-height:0;max-width:0;overflow:hidden;font-size:0em;padding:0;margin:0"></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jun 27, 2019 at 4:06 PM Dillan Cellier &lt;<a href="mailto:cellierdillan@gmail.com">cellierdillan@gmail.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><p><span style="padding:3px 10px;border-radius:5px;color:rgb(255,255,255);font-weight:bold;display:inline-block;background-color:rgb(255,0,0)">        External Email - Use Caution        </span></p><p></p><div dir="ltr">Hello MNE users,<div><br></div><div>I am seeking help with figuring out how to prevent the figures from displaying when using this function: <a href="https://martinos.org/mne/stable/generated/mne.viz.plot_topomap.html#mne.viz.plot_topomap" rel="noopener noreferrer" style="font-family:wf_segoe-ui_normal,&quot;Segoe UI&quot;,&quot;Segoe WP&quot;,Tahoma,Arial,sans-serif,serif,EmojiFont;font-size:16px" target="_blank">https://martinos.org/mne/stable/generated/mne.viz.plot_topomap.html#mne.viz.plot_topomap</a></div><div><br></div><div>In using this mne.viz.plot_topomap, my aim is to save out the figure as a .png without it opening in a new window and without me having to manually close the figure. Here is how I am using the function: </div><div><br></div><div>fig_a=plt.figure()</div><div>mne.viz.plot_topomap(data_array, pos=mne.channels.read_montage(&#39;biosemi64&#39;).pos[:64,:2])</div><div>plt.close(fig_a)<br></div><div>fig_a.savefig(&#39;/home/dcellier/data_array_topoplot.png&#39;)</div><div><br></div><div>The result is that the topomap figure is popping up and pauses the script until I close it. This is problematic because this code is nested in a for loop and will be called upon &gt;100 times. It does successfully save the topomap in the intended directory. </div><div><br></div><div>What I&#39;ve tried, to no avail: </div><div><br></div><div>import matplotlib.pyplot as plt</div><div>plt.ioff() #turning interactive plotter off<br>print(matplotlib.is_interactive()) #returns False<br>matplotlib.use(&#39;Agg&#39;)<br></div><div><br></div><div>as well as plt.close(). I also tried assigning the output of mne.viz.plot_topomap() to a variable, but it doesn&#39;t work to suppress the figure.</div><div><br></div><div>Thank you in advance for any assistance!! </div><div><br></div><div>Best wishes,</div><div>Dillan </div><div><br></div></div>
_______________________________________________<br>
Mne_analysis mailing list<br>
<a href="mailto:Mne_analysis@nmr.mgh.harvard.edu" target="_blank">Mne_analysis@nmr.mgh.harvard.edu</a><br>
<a href="https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis" rel="noreferrer" target="_blank">https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis</a></blockquote></div>