From: Michael H. <mh...@al...> - 2005-09-06 20:17:03
|
Zoe Cournia wrote: > I am trying to plot a series of files with python and gnuplot named > sequentially as: > > temp/spectra1.dat > temp/spectra2.dat > temp/spectra3.dat ..... and so on > > I am generating each of these files in a loop and try to open them and > store each file in a postscript file as: > >> for i in range(1,detectors): >> data = open('temp/spectra'+str(i)+'.dat','r') >> g.plot(data) >> g.hardcopy('gp_test'+str(i)+'.ps', enhanced=0, color=1) >> g.q To plot a file, you don't open the file using Python but rather pass the plot method a Gnuplot.File object, like g.plot(Gnuplot.File('temp/spectra'+str(i)+'.dat')) With that change, I think it should work. (Of course, you could alternatively open the file using python, read the data into a python array, then plot the array, but that approach doesn't have any advantages unless you want to process the data before plotting it.) Michael |