## Re: [Matplotlib-users] How do you Plot data generated by a python script?

 Re: [Matplotlib-users] How do you Plot data generated by a python script? From: Jonny Milliken - 2011-08-26 13:42:12 Attachments: Message as HTML ```You could always just save it as a list and then plot from there? The average calculation is a bit redundant though, I'm sure theres a better way of doing it import pylab import numpy >>f = open( 'myfile.txt','r') mass_store =[] >>for line in f: >>if line != ' ': >> line = line.strip() # Strips end of line character >> columns = line.split() # Splits into coloumn >> mass = columns[8] # Column which contains mass values >> print(mass) mass_store.append(mass) >> pylab.plot(range(len(mass_store)),mass_store) pylab.plot(range(len(mass_store)),[numpy.mean(mass_store)]*len(mass_store)) pylab.show() (or pylab.savefig('location.png') to save ) Jonny On 24 August 2011 19:46, surfcast23 wrote: > > I am fairly new to programing and have a question regarding matplotlib. I > wrote a python script that reads in data from the outfile of another > program > then prints out the data from one column. > > f = open( 'myfile.txt','r') > for line in f: > if line != ' ': > line = line.strip() # Strips end of line character > columns = line.split() # Splits into coloumn > mass = columns[8] # Column which contains mass values > print(mass) > > What I now need to do is have matplotlib take the values printed in 'mass' > and plot the sum of the values over the average of the values. I have read > the documents on the matplotlib website, but they are don't really address > how to get data from a script(or I just did not see it). If anyone can > point > me to some documentation that explains how I do this it would be really > appreciated. > Thanks in advance > > -- > View this message in context: > http://old.nabble.com/How-do-you-Plot-data-generated-by-a-python-script--tp32328822p32328822.html > Sent from the matplotlib - users mailing list archive at Nabble.com. > > > > ------------------------------------------------------------------------------ > EMC VNX: the world's simplest storage, starting under \$10K > The only unified storage solution that offers unified management > Up to 160% more powerful than alternatives and 25% more efficient. > Guaranteed. http://p.sf.net/sfu/emc-vnx-dev2dev > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users@... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > ```