[yt-users] Problem making line plots

Yuxiao Dai yuxiao.dai at nyu.edu
Sat Mar 12 18:10:44 PST 2016


Problem solved. Thank you so much.

On Sat, Mar 12, 2016 at 8:51 PM, Nathan Goldbaum <nathan12343 at gmail.com>
wrote:

> 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).
>
> The easiest fix is to tell matplotlib to use the non-interactive agg
> backend. Add the following to the top of your script:
>
> import matplotlib
> matplitlib.use('agg')
>
> -Nathan
>
> On Sat, Mar 12, 2016 at 6:33 PM, Yuxiao Dai <yuxiao.dai at nyu.edu> wrote:
>
>> Dear all,
>>
>>
>> I tried to inspect the magnetic field profile in one snap of my enzo
>> output with the code:
>>
>> #############################################
>>
>> from yt.mods import * # set up our namespace
>>
>> import numpy as np
>>
>> import pylab as P
>>
>> def _BMag(field, data):
>>
>>     return np.sqrt(data["Bx"] * data["Bx"] + data["By"] * data["By"] +
>> data["Bz"] * data["Bz"])
>>
>>     add_field("BMag", function=_BMag)
>>
>>
>>     c = pf.h.find_max('BMag')[1]
>>
>>     ax = 0
>>
>>     ray = pf.h.ortho_ray(ax, (c[1], c[2]))
>>
>>
>>
>>     P.subplot(212)
>>
>>     P.semilogy(ray['x'], ray['BMag'])
>>
>>     P.xlabel('x')
>>
>>     P.ylabel('BMag')
>>
>>     print "works"
>>
>>     P.savefig("BMag_lineplot.png")
>>
>> #############################################
>>
>> But keep getting this error message.
>>
>> #############################################
>>
>> (yt-x86_64)[yd742 at ria run5]$ python ytplots_BMag_lineplot_dai.py
>>
>> yt : [INFO     ] 2016-03-12 19:19:31,279 Parameters: current_time
>>       = 0
>>
>> yt : [INFO     ] 2016-03-12 19:19:31,279 Parameters: domain_dimensions
>>       = [128  64  64]
>>
>> yt : [INFO     ] 2016-03-12 19:19:31,279 Parameters: domain_left_edge
>>       = [-6000. -3000. -3000.]
>>
>> yt : [INFO     ] 2016-03-12 19:19:31,280 Parameters: domain_right_edge
>>       = [ 6000.  3000.  3000.]
>>
>> yt : [INFO     ] 2016-03-12 19:19:31,280 Parameters:
>> cosmological_simulation   = 0.0
>>
>> Parsing Hierarchy 100%
>> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| Time:
>> 00:00:00
>>
>> yt : [INFO     ] 2016-03-12 19:19:31,285 Gathering a field list (this may
>> take a moment.)
>>
>> yt : [INFO     ] 2016-03-12 19:19:31,290 Adding unknown field Phi to list
>> of fields
>>
>> yt : [INFO     ] 2016-03-12 19:19:31,290 Adding unknown field
>> B_Vorticity2 to list of fields
>>
>> yt : [INFO     ] 2016-03-12 19:19:31,290 Adding unknown field
>> B_Vorticity3 to list of fields
>>
>> yt : [INFO     ] 2016-03-12 19:19:31,290 Adding unknown field
>> B_Vorticity1 to list of fields
>>
>> yt : [INFO     ] 2016-03-12 19:19:31,290 Adding unknown field B_Div to
>> list of fields
>>
>> 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)
>>
>> yt : [INFO     ] 2016-03-12 19:19:32,705 Getting field x from 4
>>
>> Traceback (most recent call last):
>>
>>   File "ytplots_BMag_lineplot_dai.py", line 45, in <module>
>>
>>     P.subplot(212)
>>
>>   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
>>
>>     fig = gcf()
>>
>>   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
>>
>>     return figure()
>>
>>   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
>>
>>     **kwargs)
>>
>>   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
>>
>>     return new_figure_manager_given_figure(num, figure)
>>
>>   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
>>
>>     window = Tk.Tk()
>>
>>   File
>> "/home/yd742/software/withpysci/yt-x86_64/lib/python2.7/lib-tk/Tkinter.py",
>> line 1745, in __init__
>>
>>     self.tk = _tkinter.create(screenName, baseName, className,
>> interactive, wantobjects, useTk, sync, use)
>>
>> _tkinter.TclError: no display name and no $DISPLAY environment variable
>>
>> #############################################
>>
>> I'm using yt
>>
>> Version = 2.6.1
>>
>> Changeset = c994959ed3be
>>
>> =======================
>>
>> I would very much appreciate it if anyone could help me on this.
>>
>>
>> Thank you so much.
>>
>>
>> Regards,
>>
>> Dai
>>
>> _______________________________________________
>> yt-users mailing list
>> yt-users at lists.spacepope.org
>> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>>
>>
>
> _______________________________________________
> yt-users mailing list
> yt-users at lists.spacepope.org
> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20160312/1f36426a/attachment.htm>


More information about the yt-users mailing list