From: Jeremy C. <jer...@gm...> - 2005-12-08 15:09:16
|
I wrote this python script to read a file and get data from it to plot. However, it makes all the plot colors the same fuschia color.=20 That, of course, doesn't help me very much. I have done a similar script that automatically creates different colors for each plot. I was wondering if someone could help me discover what is wrong. I have pasted my script below. Thanks, Jeremy 1 #! /usr/local/bin/python2.4 2 import string, re, sys 3 import Gnuplot 4 5 print "Searching... ", sys.argv[1] 6 Output =3D file(sys.argv[1],'r') 7 8 OutLines =3D Output.readlines() 9 10 tallysearch =3D r'\ +(\d\.\d{4,5}E[+-]\d{2})\ +(\d\.\d{4,5}E[+-]\d{2})\ ?(\d\.\d{4})' 11 # \ +(\d\.\d{4}E[+-]\d{2}) 12 # \ ?(\d\.\d{4})''' 13 TallySearch =3D re.compile(tallysearch) 14 15 Result =3D [] 16 Tallies =3D 0 17 result =3D {} 18 result['Energy'] =3D [] 19 result['Flux'] =3D [] 20 result['Error'] =3D [] 21 Result.append(result) 22 23 print Result[Tallies] 24 25 for line in OutLines: 26 Tally =3D TallySearch.match(line) 27 if Tally: 28 Result[Tallies]['Energy'].append(float(Tally.group(1))) 29 Result[Tallies]['Flux'].append(float(Tally.group(2))) 30 Result[Tallies]['Error'].append(float(Tally.group(3))) 31 # Result[Tallies].append([energy, flux, error]) 32 33 if Tally.group(1) =3D=3D '1.0000E+01': 34 Tallies =3D Tallies+1 35 Result.append(result) 36 37 GP =3D Gnuplot.Gnuplot(debug=3D1) 38 39 g0 =3D Gnuplot.Data(Result[0]['Energy'], Result[0]['Flux'], title=3D'50 cm', with=3D'lines') 40 g2 =3D Gnuplot.Data(Result[2]['Energy'], Result[2]['Flux'], title=3D'100 cm', with=3D'histeps') 41 g4 =3D Gnuplot.Data(Result[4]['Energy'], Result[4]['Flux'], title=3D'150 cm', with=3D'histeps') 42 g6 =3D Gnuplot.Data(Result[6]['Energy'], Result[6]['Flux'], title=3D'200 cm', with=3D'histeps') 43 g1 =3D Gnuplot.Data(Result[1]['Energy'], Result[1]['Flux'], title=3D'50 cm', with=3D'histeps') 44 g3 =3D Gnuplot.Data(Result[3]['Energy'], Result[3]['Flux'], title=3D'100 cm', with=3D'histeps') 45 g5 =3D Gnuplot.Data(Result[5]['Energy'], Result[5]['Flux'], title=3D'150 cm', with=3D'histeps') 46 g7 =3D Gnuplot.Data(Result[7]['Energy'], Result[7]['Flux'], title=3D'200 cm', with=3D'histeps') 47 GP('set logscale y') 48 GP.xlabel('Energy (MeV)') 49 GP.ylabel('Flux (cm^{-2})') 50 GP.plot(g0,g2,g4,g6) |