|
Dear all I have a problem in producing a nice graph axis from some data I have; the data contains events ( e.g. when a student starts to us an IT facility ) happening on particular dates throughout the year. The data has been collected from 1st
August 2008 and is ongoing. “Management” want comparisons between years to see if this year is showing different pattern from last year and so on for future years; the problem arises in that they want the origin / left hand end of the X axis to be the start
of the data collection year ( i.e. 1st August ) – I have created a ‘year’ variable which allows me to ‘categorise’ the chart and produce different lines for each year and by cumbersome syntax I have managed to get the scale starting at the required
point – BUT – the labels show the day within the year as a number and I can’t see a way of getting a set of meaningful labels on the axis. I’ve tried using value labels for the day within the year / time period ( 1 = “1st Aug” / 2 = “1st
Sep” etc. ) but this has no effect. I have included the syntax that I use to generate the chart in the hope that someone has some bright ideas on this – if they don’t it will be a lovely puzzle to pose at Directions in November !!! There is no immediate rush for this as I
can produce the charts but “management” want better looking charts to pass on to “senior management” ! Best Wishes John S. Lemon Directorate of Information Technology (DIT) -
University of Aberdeen Edward Wright Building: Room G51 Tel: +44 1224 273350 Fax: +44 1224 273372 * Date and Time Wizard: Day_of_Year. COMPUTE Day_of_Year=XDATE.JDAY(wdateon). VARIABLE LABELS Day_of_Year "Day within Year ( 1st August to 31st July )". VARIABLE LEVEL Day_of_Year(SCALE). FORMATS Day_of_Year(F5.0). VARIABLE WIDTH Day_of_Year(5). DO IF ( ( XDATE.JDAY(wdateon) ) LE 212 ). COMPUTE Day_of_Year = 365 + Day_of_Year - 212. ELSE IF ( ( XDATE.JDAY(wdateon) ) GT 212 ). COMPUTE Day_of_Year = Day_of_Year - 212 . END IF. DATASET ACTIVATE DataSet1. * Chart Builder. GGRAPH /GRAPHDATASET NAME="graphdataset" VARIABLES=Day_of_Year COUNT()[name="COUNT"] yeer
MISSING=LISTWISE REPORTMISSING=NO /GRAPHSPEC SOURCE=INLINE TEMPLATE=[ "D:\UserStats\Analysis_Detailed\Wireless\Sessions_by_Year.sgt"]. BEGIN GPL SOURCE: s=userSource(id("graphdataset")) DATA: Day_of_Year=col(source(s), name("Day_of_Year")) DATA: COUNT=col(source(s), name("COUNT")) DATA: yeer=col(source(s), name("yeer"), unit.category()) GUIDE: axis(dim(1), label("Day within Year ( 1st August to 31st July )")) GUIDE: axis(dim(2), label("Count")) GUIDE: legend(aesthetic(aesthetic.color.interior), label(" Year ( from 1st August to 31st July ) ", "")) SCALE: cat(aesthetic(aesthetic.color.interior), include("1", "2")) ELEMENT: line(position(Day_of_Year*COUNT), color.interior(yeer), missing.wings()) END GPL. The University of Aberdeen is a charity registered in Scotland, No SC013683. |
|
Here are a couple of ideas: Use the sort.data function. Help
indicates that this is used for categorical data so it might not work. Try the origin function on the X
axis. Typically it’s used to create floating bars or areas on the y axis.
When I have some time later this
week, I’ll play with this. It would help if I had an example of the data. From: SPSSX(r) Discussion
[mailto:[hidden email]] On Behalf Of Lemon, John S. Dear all I have a problem in producing a nice graph
axis from some data I have; the data contains events ( e.g. when a student
starts to us an IT facility ) happening on particular dates throughout the
year. The data has been collected from 1st August 2008 and is
ongoing. “Management” want comparisons between years to see if this
year is showing different pattern from last year and so on for future years;
the problem arises in that they want the origin / left hand end of the X axis to
be the start of the data collection year ( i.e. 1st August ) –
I have created a ‘year’ variable which allows me to
‘categorise’ the chart and produce different lines for each year
and by cumbersome syntax I have managed to get the scale starting at the
required point – BUT – the labels show the day within the year as a
number and I can’t see a way of getting a set of meaningful labels on the
axis. I’ve tried using value labels for the day within the year / time
period ( 1 = “1st Aug” / 2 = “1st
Sep” etc. ) but this has no effect. I have included the syntax that I use to
generate the chart in the hope that someone has some bright ideas on this
– if they don’t it will be a lovely puzzle to pose at Directions in
November !!! There is no immediate rush for this as I can produce the charts
but “management” want better looking charts to pass on to
“senior management” ! Best Wishes John S. Lemon Directorate of Information
Technology (DIT) - University of Aberdeen Edward Wright
Building: Room G51 Tel: +44 1224 273350 Fax: +44 1224 273372 * Date and Time Wizard: Day_of_Year. COMPUTE Day_of_Year=XDATE.JDAY(wdateon). VARIABLE LABELS Day_of_Year "Day
within Year ( 1st August to 31st July )". VARIABLE LEVEL Day_of_Year(SCALE). FORMATS Day_of_Year(F5.0). VARIABLE WIDTH Day_of_Year(5). DO IF ( ( XDATE.JDAY(wdateon) ) LE 212 ). COMPUTE Day_of_Year = 365 + Day_of_Year -
212. ELSE IF ( ( XDATE.JDAY(wdateon) ) GT 212 ). COMPUTE Day_of_Year = Day_of_Year - 212 . END IF. DATASET ACTIVATE DataSet1. * Chart Builder. GGRAPH /GRAPHDATASET
NAME="graphdataset" VARIABLES=Day_of_Year
COUNT()[name="COUNT"] yeer MISSING=LISTWISE
REPORTMISSING=NO /GRAPHSPEC SOURCE=INLINE TEMPLATE=[
"D:\UserStats\Analysis_Detailed\Wireless\Sessions_by_Year.sgt"]. BEGIN GPL SOURCE:
s=userSource(id("graphdataset")) DATA: Day_of_Year=col(source(s),
name("Day_of_Year")) DATA: COUNT=col(source(s),
name("COUNT")) DATA: yeer=col(source(s),
name("yeer"), unit.category()) GUIDE: axis(dim(1), label("Day
within Year ( 1st August to 31st July )")) GUIDE: axis(dim(2),
label("Count")) GUIDE:
legend(aesthetic(aesthetic.color.interior), label(" Year ( from 1st August
to 31st July ) ", "")) SCALE:
cat(aesthetic(aesthetic.color.interior), include("1", "2")) ELEMENT:
line(position(Day_of_Year*COUNT), color.interior(yeer), missing.wings()) END GPL.
|
|
I have now created some sample data – if anyone else wants to experiment then I can supply the link.
J Best Wishes John S. Lemon Directorate of Information Technology (DIT) -
University of Aberdeen Edward Wright Building: Room G51 Tel: +44 1224 273350 Fax: +44 1224 273372 The University of Aberdeen is a charity registered in Scotland, No SC013683. |
| Free forum by Nabble | Edit this page |
