Re: superimposed plots using SHOW command
- To: mathgroup at smc.vnet.net
- Subject: [mg108314] Re: superimposed plots using SHOW command
- From: Bill Rowe <readnews at sbcglobal.net>
- Date: Sat, 13 Mar 2010 07:58:03 -0500 (EST)
On 3/12/10 at 7:08 AM, jihane.ajaja at mail.mcgill.ca (jihane) wrote: >I have a question and your help would be very appreciated.Here is my >question: >How can I use the command SHOW to produce superimposed plots that >are generated in a loop? The lists used to generate the plots are >initialized before the start of the loop and when the program goes >through a loop it produces the plots from the full lists then it >goes out from the loop and empty the lists and go again through the >list. I am doing it manually right now and it is very tedious. I >have to export the lists everytime the program goes through the loop >and then in an other notebook import these lists and use show to >plot them all together in one plot; >data1zRAW = ReadList["ZDVNew - Parabola1.txt"]; plot1zRAW = >ListLinePlot[data1zRAW, PlotRange -> All, Joined -> True, Frame -> >True, FrameLabel -> {"Time (sec)", "Measured Acceleration >(g/\!\(\*SubscriptBox[\"g\", \"0\"]\))"}, LabelStyle -> >Directive[15], ImageSize -> Scaled[1]]; <snip> Here are two ways to do what you want. First would be to take advantage of the fact ListLinePlot can accept several data sets at once to plot. That is ListLinePlot[ReadList/@FileNames["*Parabola*.txt"], options...] will create a plot showing the data in each of the files. Here, I assume there is no file with extension .txt that includes the name Parabola that you do not want plotted in the current working directory An alternative approach would be generate each plot then combine them with Show. The simplest version of this would be Show@@(ListLinePlot[ReadLIst[#],options]&/@FileNames["*Parabola*.txt"]) While this will combine all of the plots the result may not be what you want. The problem is Show sets common default options according to how they are set for the first plot. In particular, if a plot range of 0 to 1 is used in the first plot, this plot range will be used in the resulting graphic even though a later plot might need a larger plot range to show all of the data. This issue with plot range can be over come by doing Show[ListLinePlot[ReadLIst[#],options]&/@FileNames["*Parabola*.txt"],PlotRa= nge->All] And you could add any other additional option required using this method. But, my preference would be the first approach since it will color each of the curves differently.