Dear All, How we can use yt to plot ASCII files like gnuplot. Any simple example will be really appreciated. Thanks, Regards Amol
You can use numpy's loadtxt() to load columns of data into memory and use
the plot function to plot them.
http://docs.scipy.org/doc/numpy/reference/generated/numpy.loadtxt.html
so in yt it would look something like
from yt.mods import *
...some yt stuff that saves to myfile.txt...
import numpy as na
col1, col2 = na.loadtxt("myfile.txt", usecols=(0,1))
pylab.plot(col1,col2)
This is assuming your ASCII data is in columns. Essentially starting from
import numpy, this is just a matplotlib script which can be separate from
the yt stuff above.
From
G.S.
On Mon, Jul 2, 2012 at 12:50 AM, Amol Holkundkar
Dear All,
How we can use yt to plot ASCII files like gnuplot. Any simple example will be really appreciated.
Thanks,
Regards Amol
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
Hey there, I don't think it is directly in there, but I am not too sure about this. You could just use matplotlib. Basically you could do something like this: import matplotlib.pyplot as plt plt.plot([1,2,3,4], [1,4,9,16]) plt.show() Pylab would be possible as well, maybe even better, as it also gives you the math namespace. Hope that helps. All the best Hannes PS: For actually opening a file you might want to try: plt.plotfile(/fname/,/cols=(0/,/)/,/plotfuncs=None/,/comments='#'/,/skiprows=0/,/checkrows=5/,/delimiter='/,/'/,/names=None/,/subplots=True/,/newfig=True/,/**kwargs/) plt.plotfile(fname, (0,1,2), subplots=False) Which would plot the second and third column of the file 'fname' against the first one. On 07/02/2012 09:50 AM, Amol Holkundkar wrote:
Dear All,
How we can use yt to plot ASCII files like gnuplot. Any simple example will be really appreciated.
Thanks,
Regards Amol
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
participants (3)
-
Amol Holkundkar
-
Geoffrey So
-
Hannes Mohr