> From: Sherlock, Ric > > > From: PackRat > > > > How would the interior lines (Days, Xticpos, Values) need to be > changed > > if the data were instead a table with two columns: Date (format YYYY- > > MM- > > DD) and Value? For even greater flexibility, assume that NOT every > > date (including occasionally the first day) within a month has any > data > > (I'm thinking of stock market data as one example). I presume that > > somehow you'd have to check for a change in the month and use that to > > calculate the Xticpos? I'm VERY interested in seeing your solution! > > Thanks in advance! > > Use dates.ijs to convert dates to day numbers. > 1st of the month of earliest date is base date - subtract from day > numbers to get x values corresponding to y values you want to plot. > Subtract the base date daynumber from day number of the 1st of each > month to get the Xticpos.
Actually it is not necessary to subtract the base date: Download daily DJIA data from Yahoo for 2007 & 2008 and save in ~temp: "http://finance.yahoo.com/q/hp?s=^DJI&a=00&b=1&c=2007&d=11&e=31&f=2008&g=d" load 'dates plot tables/csv' sFname=: jpath '~temp\DJIA20072008.csv' data=: readcsv sFname NB. oldest dates are at bottom Months=: _4]\'Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec' Dates=: getdate"1 }. >{."1 data Months2plot=: ~. }:"1 |. Dates idx=: <: , }."1 Months2plot Xlabels=: , idx { Months Xticpos=: todayno 1 ,~"1 Months2plot NB. Firsts of Month Xvals=: todayno Dates Yvals=: 0". > }. 1 {"1 data NB. Open value ('xlabel ',Xlabels,';xticpos ',":Xticpos) plot Xvals;Yvals ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
