<div dir="ltr">This is an issue with matplotlib. When pyplot tries to open a plotting window, it dies because you don't have an X11 server set up (probably because you haven't set up ssh forwarding).<div><br></div><div>The easiest fix is to tell matplotlib to use the non-interactive agg backend. Add the following to the top of your script:</div><div><br></div><div>import matplotlib</div><div>matplitlib.use('agg')</div><div><br></div><div>-Nathan</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Mar 12, 2016 at 6:33 PM, Yuxiao Dai <span dir="ltr"><<a href="mailto:yuxiao.dai@nyu.edu" target="_blank">yuxiao.dai@nyu.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_default">







<p style="font-family:georgia,serif"><span>Dear all, </span></p><p style="font-family:georgia,serif"><span><br></span></p><p style="font-family:georgia,serif"><span><font size="4">I tried to inspect the magnetic field profile in one snap of my enzo output with the code: </font></span></p><br>#############################################<br><br>from yt.mods import * # set up our namespace<br><br>import numpy as np<br><br>import pylab as P<br><br>def _BMag(field, data):<br><br>    return np.sqrt(data["Bx"] * data["Bx"] + data["By"] * data["By"] + data["Bz"] * data["Bz"])<br><br>    add_field("BMag", function=_BMag)<br><br><br>    c = pf.h.find_max('BMag')[1]<br><br>    ax = 0<br><br>    ray = pf.h.ortho_ray(ax, (c[1], c[2]))<br><br>    <br><br>    P.subplot(212)<br><br>    P.semilogy(ray['x'], ray['BMag'])<br><br>    P.xlabel('x')<br><br>    P.ylabel('BMag')<br><br>    print "works"<br><br>    P.savefig("BMag_lineplot.png")<br><br>#############################################<p style="font-family:georgia,serif"><font size="4">But keep getting this error message. </font></p><p style="font-family:georgia,serif"><span style="font-family:arial,sans-serif">#############################################</span><br></p><p style="font-family:georgia,serif"><span>(yt-x86_64)[yd742@ria run5]$ python ytplots_BMag_lineplot_dai.py</span></p>
<p style="font-family:georgia,serif"><span><font color="#cccccc">yt : [INFO     ] 2016-03-12 19:19:31,279 Parameters: current_time              = 0</font></span></p>
<p style="font-family:georgia,serif"><span><font color="#cccccc">yt : [INFO     ] 2016-03-12 19:19:31,279 Parameters: domain_dimensions         = [128  64  64]</font></span></p>
<p style="font-family:georgia,serif"><span><font color="#cccccc">yt : [INFO     ] 2016-03-12 19:19:31,279 Parameters: domain_left_edge          = [-6000. -3000. -3000.]</font></span></p>
<p style="font-family:georgia,serif"><span><font color="#cccccc">yt : [INFO     ] 2016-03-12 19:19:31,280 Parameters: domain_right_edge         = [ 6000.  3000.  3000.]</font></span></p>
<p style="font-family:georgia,serif"><span><font color="#cccccc">yt : [INFO     ] 2016-03-12 19:19:31,280 Parameters: cosmological_simulation   = 0.0</font></span></p>
<p style="font-family:georgia,serif"><span><font color="#cccccc">Parsing Hierarchy 100% ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| Time: 00:00:00 </font></span></p>
<p style="font-family:georgia,serif"><span><font color="#cccccc">yt : [INFO     ] 2016-03-12 19:19:31,285 Gathering a field list (this may take a moment.)</font></span></p>
<p style="font-family:georgia,serif"><span><font color="#cccccc">yt : [INFO     ] 2016-03-12 19:19:31,290 Adding unknown field Phi to list of fields</font></span></p>
<p style="font-family:georgia,serif"><span><font color="#cccccc">yt : [INFO     ] 2016-03-12 19:19:31,290 Adding unknown field B_Vorticity2 to list of fields</font></span></p>
<p style="font-family:georgia,serif"><span><font color="#cccccc">yt : [INFO     ] 2016-03-12 19:19:31,290 Adding unknown field B_Vorticity3 to list of fields</font></span></p>
<p style="font-family:georgia,serif"><span><font color="#cccccc">yt : [INFO     ] 2016-03-12 19:19:31,290 Adding unknown field B_Vorticity1 to list of fields</font></span></p>
<p style="font-family:georgia,serif"><span><font color="#cccccc">yt : [INFO     ] 2016-03-12 19:19:31,290 Adding unknown field B_Div to list of fields</font></span></p>
<p style="font-family:georgia,serif"><span><font color="#cccccc">yt : [INFO     ] 2016-03-12 19:19:32,705 Max Value is 8.56382e-05 at -2501.9531250000000000 29.2968750000000000 228.5156250000000000 in grid EnzoGrid_0005 at level 3 (16, 16, 15)</font></span></p>
<p style="font-family:georgia,serif"><span><font color="#cccccc">yt : [INFO     ] 2016-03-12 19:19:32,705 Getting field x from 4</font></span></p>
<p style="font-family:georgia,serif"><span>Traceback (most recent call last):</span></p>
<p style="font-family:georgia,serif"><span>  File "ytplots_BMag_lineplot_dai.py", line 45, in <module></span></p>
<p style="font-family:georgia,serif"><span>    P.subplot(212)</span></p>
<p style="font-family:georgia,serif"><span>  File "/home/yd742/software/withpysci/yt-x86_64/lib/python2.7/site-packages/matplotlib-1.3.0-py2.7-linux-x86_64.egg/matplotlib/pyplot.py", line 896, in subplot</span></p>
<p style="font-family:georgia,serif"><span>    fig = gcf()</span></p>
<p style="font-family:georgia,serif"><span>  File "/home/yd742/software/withpysci/yt-x86_64/lib/python2.7/site-packages/matplotlib-1.3.0-py2.7-linux-x86_64.egg/matplotlib/pyplot.py", line 450, in gcf</span></p>
<p style="font-family:georgia,serif"><span>    return figure()</span></p>
<p style="font-family:georgia,serif"><span>  File "/home/yd742/software/withpysci/yt-x86_64/lib/python2.7/site-packages/matplotlib-1.3.0-py2.7-linux-x86_64.egg/matplotlib/pyplot.py", line 423, in figure</span></p>
<p style="font-family:georgia,serif"><span>    **kwargs)</span></p>
<p style="font-family:georgia,serif"><span>  File "/home/yd742/software/withpysci/yt-x86_64/lib/python2.7/site-packages/matplotlib-1.3.0-py2.7-linux-x86_64.egg/matplotlib/backends/backend_tkagg.py", line 79, in new_figure_manager</span></p>
<p style="font-family:georgia,serif"><span>    return new_figure_manager_given_figure(num, figure)</span></p>
<p style="font-family:georgia,serif"><span>  File "/home/yd742/software/withpysci/yt-x86_64/lib/python2.7/site-packages/matplotlib-1.3.0-py2.7-linux-x86_64.egg/matplotlib/backends/backend_tkagg.py", line 87, in new_figure_manager_given_figure</span></p>
<p style="font-family:georgia,serif"><span>    window = Tk.Tk()</span></p>
<p style="font-family:georgia,serif"><span>  File "/home/yd742/software/withpysci/yt-x86_64/lib/python2.7/lib-tk/Tkinter.py", line 1745, in __init__</span></p>
<p style="font-family:georgia,serif"><span>    <a href="http://self.tk" target="_blank">self.tk</a> = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)</span></p>
<p style="font-family:georgia,serif"><span>_tkinter.TclError: no display name and no $DISPLAY environment variable</span></p><p style="font-family:georgia,serif"><span><span style="font-family:arial,sans-serif">#############################################</span><br></span></p><p style="font-family:georgia,serif"><span style="font-size:12.8px">I'm using yt</span><br></p><p style="font-size:12.8px;font-family:georgia,serif">Version = 2.6.1</p><p style="font-size:12.8px;font-family:georgia,serif"></p><p style="font-size:12.8px;font-family:georgia,serif">Changeset = c994959ed3be</p><p style="font-size:12.8px;font-family:georgia,serif">=======================<br></p><p style="font-size:12.8px"><font face="georgia, serif">I would very much appreciate it if anyone could help me on this. </font></p><p style="font-size:12.8px"><font face="georgia, serif"><br></font></p><p style="font-size:12.8px"><font face="georgia, serif">Thank you so much. </font></p><p style="font-size:12.8px"><font face="georgia, serif"><br></font></p><p style="font-family:georgia,serif"><span></span></p><p style="font-size:12.8px"><font face="georgia, serif">Regards, </font></p><span class="HOEnZb"><font color="#888888"><p style="font-size:12.8px"><font face="georgia, serif">Dai</font></p></font></span></div></div>
<br>_______________________________________________<br>
yt-users mailing list<br>
<a href="mailto:yt-users@lists.spacepope.org">yt-users@lists.spacepope.org</a><br>
<a href="http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org" rel="noreferrer" target="_blank">http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org</a><br>
<br></blockquote></div><br></div>