Re: How to plot a date file? Some questions, some solutions.
- To: mathgroup at smc.vnet.net
- Subject: [mg4854] Re: How to plot a date file? Some questions, some solutions.
- From: vvs124 at rsphy1.anu.edu.au (Victoria Steblina)
- Date: Thu, 26 Sep 1996 22:42:15 -0400
- Organization: Australian National University
- Sender: owner-wri-mathgroup at wolfram.com
lbliao <lbliao at alumni.caltech.edu> wrote: >The following is a file that I want to plot >as either R versus FQ or DG versus FQ. >Note it has three columns of numbers preceeded >by two letter identifiers R_, DG, FQ, where >R_ is a two letter identifier. _ denotes >white space. > > >R 999.1E-3,DG 000.0E+0,FQ 1.000E+3 >R 999.1E-3,DG 000.0E+0,FQ 1.023E+3 >R 999.1E-3,DG 000.0E+0,FQ 1.047E+3 >R 999.1E-3,DG 000.0E+0,FQ 1.072E+3 >R 999.1E-3,DG 000.0E+0,FQ 1.096E+3 >R 999.1E-3,DG 000.0E+0,FQ 1.122E+3 >R 999.1E-3,DG 000.0E+0,FQ 1.148E+3 >R 999.1E-3,DG 000.0E+0,FQ 1.175E+3 >R 999.1E-3,DG 000.0E+0,FQ 1.202E+3 >R 999.1E-3,DG 000.0E+0,FQ 1.230E+3 >R 998.9E-3,DG 000.0E+0,FQ 7.244E+3 >R 998.9E-3,DG 000.0E+0,FQ 7.413E+3 >R 999.0E-3,DG 000.0E+0,FQ 7.585E+3 >R 998.9E-3,DG 000.0E+0,FQ 7.762E+3 >R 998.9E-3,DG 000.0E+0,FQ 7.943E+3 >R 998.9E-3,DG 000.0E+0,FQ 8.128E+3 >R 999.0E-3,DG 000.0E+0,FQ 8.317E+3 >R 999.0E-3,DG 000.0E+0,FQ 8.511E+3 >R 999.0E-3,DG 000.0E+0,FQ 8.709E+3 >R 999.0E-3,DG 000.0E+0,FQ 8.912E+3 >R 999.0E-3,DG 000.0E+0,FQ 9.120E+3 >R 999.0E-3,DG 000.0E+0,FQ 9.332E+3 >R 998.8E-3,DG-000.0E+0,FQ 9.999E+3 >R 998.8E-3,DG-000.0E+0,FQ 10.00E+3 --- skip --- >The first problem is to separate the list into three columns >a=ReadList["c:\\file", Word, >WordSeparators -> {"R", ",DG", ",FQ"}, >RecordLists->True] > >For RecordList -> True, see page 182, >For WordSeparators -> {}, see p 496, > >This has one PROBLEM. Although all the three number fields are separated, >they are not numbers any more, but words. > >The second problem is to get any two columns from the three columns so that >they can be plotted I do not see how to directly get two columns other than > transposing getting the rows, and then transposing back again, ie > >Transpose[Transpose[a][[{1,3}]]] Try this: a=ReadList["data", Word, WordSeparators -> {"R", ",DG", ",FQ"}, RecordLists->True]//ToString; (* Make it a string for further replacements*) That will convert all "exponential" notations into Mma number format (unless I misread something, this is what you want) and then convert string "a" to the list of symbols: toSymbols = StringReplace[a, {"E" -> " 10^"}] // ToExpression; Build up lists for R, DG, and FQ respectively: Rlist = First /@ toSymbols // Flatten DGlist = Transpose[{Transpose[toSymbols][[2]]}] // Flatten FQlist = Last /@ toSymbols // Flatten (local) Out[79]= {0.9991, 0.9991, 0.9991, 0.9991, 0.9991, 0.9991, 0.9991, 0.9991, 0.9991, 0.9991, 0.9989, 0.9989, 0.999, 0.9989, 0.9989, 0.9989, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.9988, 0.9988} (local) Out[80]= {0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.} (local) Out[81]= {1000., 1023., 1047., 1072., 1096., 1122., 1148., 1175., 1202., 1230., 7244., 7413., 7585., 7762., 7943., 8128., 8317., 8511., 8709., 8912., 9120., 9332., 9999., 10000.} Transpose two lists (will produce 2 tables of values: R vs FQ and DG vs FQ) and ListPlot them: RvsFQ = ListPlot @ Transpose[{FQlist, Rlist}]; DGvsFQ = ListPlot @ Transpose[{FQlist, DGlist}]; Hope it helps a bit. Victoria _______________________________________________________________ Victoria Steblina vvs124 at rsphy1.anu.edu.au Optical Sciences Centre Australian National University ==== [MESSAGE SEPARATOR] ====