Login  Register

Re: form.line position with date-formatted axes

Posted by Bruce Weaver on Dec 16, 2022; 8:11pm
URL: http://spssx-discussion.165.s1.nabble.com/form-line-position-with-date-formatted-axes-tp5741098p5741100.html

Hi Jon.  Jeremy did have that GUIDE statement (plus a couple others) in the code he posted.  If I remove the other GUIDE statements, it still does not work.  To get the desired X-axis reference line, I have to use a numeric date variable.  But then the X-axis labels are also numeric, and I suspect Jeremy wants those labels to be formatted as dates.  So that raises another question:  Is there a way in GPL to make numeric values on the X-axis display as dates?  

Here's my code.  

NEW FILE.
DATASET CLOSE ALL.
DATA LIST FREE / Date (date11) Growth (F2.1).
BEGIN DATA
06-Sep-2020     .00
06-Apr-2020     .32
12-Aug-2020     .00
15-Jun-2020     .00
18-Jun-2020     .00
16-Jun-2020     .00
18-Jun-2020     .00
09-Aug-2020     .00
31-Jul-2020     .00
04-Sep-2020     .01
10-Oct-2020     .01
12-Oct-2020     .00
END DATA.

GGRAPH
  /GRAPHDATASET NAME="graphdataset" VARIABLES=Date Growth MISSING=LISTWISE REPORTMISSING=NO
  /GRAPHSPEC SOURCE=INLINE.
BEGIN GPL
  SOURCE: s=userSource(id("graphdataset"))
  DATA: datenum=col(source(s), name("Date"))
  DATA: Growth=col(source(s), name("Growth"))
  GUIDE: axis(dim(1), label("Date"))
  GUIDE: axis(dim(2), label("Growth"))
/**********************************************/  
  GUIDE: form.line(position(13811558400, *))
/**********************************************/  
  GUIDE: form.line(position(*, 0.2))
  ELEMENT: line(position(datenum*Growth), missing.wings())
END GPL.
* I see no reference line at X=13811558400.

COMPUTE datenum = date.
FORMATS datenum (F15.0).
LIST datenum date.

GGRAPH
  /GRAPHDATASET NAME="graphdataset" VARIABLES=Datenum Growth MISSING=LISTWISE REPORTMISSING=NO
  /GRAPHSPEC SOURCE=INLINE.
BEGIN GPL
  SOURCE: s=userSource(id("graphdataset"))
  DATA: datenum=col(source(s), name("Datenum"))
  DATA: Growth=col(source(s), name("Growth"))
  GUIDE: axis(dim(1), label("Date"))
  GUIDE: axis(dim(2), label("Growth"))
  GUIDE: form.line(position(13811558400, *))
  GUIDE: form.line(position(*, 0.2))
  ELEMENT: line(position(datenum*Growth), missing.wings())
END GPL.
* Now I see a reference line at X=13811558400, but
* the X-axis labels are no longer formatted as dates.
* I suspect Jeremy wants the reference line AND to
* have the X-axis labels formatted as dates, as they
* are in the first graph.


jkpeck wrote
If you enter those values (without the commas) in GUIDE statements, you get the reference lines you want.
  GUIDE: form.line(position(13811558400, *))
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

PLEASE NOTE THE FOLLOWING: 
1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above.
2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/).