Re: plotting time data
- To: mathgroup at smc.vnet.net
- Subject: [mg19021] Re: [mg18962] plotting time data
- From: "Tomas Garza" <tgarza at mail.internet.com.mx>
- Date: Tue, 3 Aug 1999 13:44:54 -0400
- Sender: owner-wri-mathgroup at wolfram.com
James L. Fisher [jlfisher at imt.net] wrote: > I would like to plot some time data where I have the dates and/or times on > the horizontal axis and the data on the vericle axis. What software would > I have to get inorder to plot this data over time. The data should be > plotted as points with a line joining the points. Getting the > horizontal to > be labeled with the time and/or date is the trouble . I could use ListPlot > otherwise. James, Suppose you have your data in dataPoints (I give a realistic example below), and each point correponds to a month. In[1]:= dataPoints = Table[{j, 100 + 10*(j - 1) + Random[Integer, {-5, 5}]}, {j, 1, 12}] Out[1]= {{1, 102}, {2, 106}, {3, 115}, {4, 133}, {5, 140}, {6, 152}, {7, 158}, {8, 166}, {9, 176}, {10, 191}, {11, 201}, {12, 213}} In[2]:= dateTicks = {"JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"}; Then try In[3]:= newTicks = Transpose[{Range[12], dateTicks}] Out[3]= {{1, "JAN"}, {2, "FEB"}, {3, "MAR"}, {4, "APR"}, {5, "MAY"}, {6, "JUN"}, {7, "JUL"}, {8, "AUG"}, {9, "SEP"}, {10, "OCT"}, {11, "NOV"}, {12, "DEC"}} In[4]:= ListPlot[dataPoints, PlotJoined -> True, Ticks -> {newTicks, Automatic}] Tomas Garza Mexico City