From: Salman S. <sal...@gm...> - 2016-02-10 15:13:11
|
Doh, stupid mistake, I figured it out, once I assigned the values to x, y and z using np.loadtxt, I don't need the using 1, etc.. I am not good at python but this was my first foray into writing the code. Now, I got a script that parses a massive file, extracts the data and generates a plot all from the command line. #! /usr/bin/python #import sys import numpy as np import Gnuplot, Gnuplot.PlotItems, Gnuplot.funcutils fobj = open("rwtc", "r") x, y, z = np.loadtxt(fobj, delimiter=' ', unpack=True) g = Gnuplot.Gnuplot() g.title('Dellingr RW Speed vs Time NM ') g.xlabel('time') g.ylabel('speed') g('set term png') g('set out "run.png"') g.plot(Gnuplot.Data(x, with_='line', title="x"), Gnuplot.Data(y, with_='line', title="y"), Gnuplot.Data(z, with_='line', title="z")) On Tue, Feb 9, 2016 at 6:03 PM, Salman Sheikh <sal...@gm...> wrote: > When I take the following script and run in python, I get gnuplot errors > for the data file shown below (shortened version). Any body able to see > what is wrong with my plot call? > > import numpy as np > import Gnuplot, Gnuplot.PlotItems, Gnuplot.funcutils > > fobj = open("rwtc", "r") > x, y, z = np.loadtxt(fobj, delimiter=' ', unpack=True) > > g = Gnuplot.Gnuplot() > g.title('RW Speed vs Time NM ') > g.xlabel('time') > g.ylabel('speed') > g('set term png') > g('set out "run.png"') > g.plot(Gnuplot.Data(x, using='1', with_='line', title="x"), > Gnuplot.Data(y, using='2', with_='line', title="y"), > Gnuplot.Data(z, using='3', with_='line', title="z")) > > You can use this as the file rwtc > > 0.000402 -0.000017 0.000821 > 0.000402 -0.000017 0.000821 > 0.000605 -0.000188 0.001000 > 0.000365 0.000083 0.000197 > 0.000343 0.000162 0.000060 > 0.000323 0.000214 -0.000009 > 0.000308 0.000226 0.000010 > 0.000294 0.000229 0.000047 > 0.000281 0.000232 0.000086 > 0.000266 0.000237 0.000120 > 0.000248 0.000245 0.000144 > 0.000227 0.000255 0.000160 > 0.000202 0.000266 0.000168 > 0.000174 0.000278 0.000170 > > Thanks. > > Salman > > > > > On Tue, Feb 9, 2016 at 6:00 PM, Salman Sheikh <sal...@gm...> > wrote: > >> Anybody can tell me why this file isn't working right? >> >> >> >> -- >> Even a Smile is charity :) >> - Prophet Muhammad >> >> >> > > > -- > Even a Smile is charity :) > - Prophet Muhammad > > > -- Even a Smile is charity :) - Prophet Muhammad |