|
Hi,
I started to work with GGRAPH and GPL. I've got the reference guide in front of me, anyhow I can't find solutions to the following problems. - changing the background colour of the chart. - insert a legend for two line Elements where I declared the colour (see code below). - Using GGraph and GPL inside of a Macro (there is always the following warning: GPL-Fehler: id('graphdataset') Not a quoted string: 'graphdataset'). Maybe somebody can help me? flo *** Code: GGRAPH /GRAPHDATASET NAME="graphdataset" VARIABLES= rez don dif absdiff gvar /GRAPHSPEC SOURCE=INLINE. BEGIN GPL PAGE: begin(scale(1000px,700px)) SOURCE: s=userSource(id("graphdataset")) DATA: gvar=col(source(s), name("gvar"), unit.category()) DATA: rez=col(source(s), name("rez")) DATA: don=col(source(s), name("don")) DATA: dif=col(source(s), name("dif")) DATA: absdiff= col(source(s), name("absdiff")) SCALE: linear(dim(2), max(0.25), min(-0.25)) GUIDE: axis(dim(1), label("Gemeinsame Variablen")) GUIDE: axis(dim(2), label("Korrelation")) ELEMENT: interval(position(gvar*dif), color(color.orange), color.saturation(absdiff)) ELEMENT: line(position(gvar*rez),label("Rezipienten"), color(color.red)) ELEMENT: line(position(gvar*don),label("Donoren"), color(color.blue)) PAGE: end() END GPL. |
|
1. You'll need a chart template to control the frame background. GPL
provides no styling other than aesthetics applied to data elements. Generate your chart, edit it in the chart editor changing the background color, and then save a template checking off only the color. Now you can specify that template in subsequent GGRAPH commands. 2. I assume you mean a legend title since you should get your category labels already. Here's how to get that legend title: GUIDE: legend(aesthetic(aesthetic.color), label("Your title")) The argument to the aesthetic function is the aesthetic you've specified on the ELEMENT statement. 3. Macros strip the double quotes unless you use the !QUOTE function. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of flo statistik Sent: Monday, September 24, 2007 9:31 AM To: [hidden email] Subject: GPL GGRAPH Hi, I started to work with GGRAPH and GPL. I've got the reference guide in front of me, anyhow I can't find solutions to the following problems. - changing the background colour of the chart. - insert a legend for two line Elements where I declared the colour (see code below). - Using GGraph and GPL inside of a Macro (there is always the following warning: GPL-Fehler: id('graphdataset') Not a quoted string: 'graphdataset'). Maybe somebody can help me? flo *** Code: GGRAPH /GRAPHDATASET NAME="graphdataset" VARIABLES= rez don dif absdiff gvar /GRAPHSPEC SOURCE=INLINE. BEGIN GPL PAGE: begin(scale(1000px,700px)) SOURCE: s=userSource(id("graphdataset")) DATA: gvar=col(source(s), name("gvar"), unit.category()) DATA: rez=col(source(s), name("rez")) DATA: don=col(source(s), name("don")) DATA: dif=col(source(s), name("dif")) DATA: absdiff= col(source(s), name("absdiff")) SCALE: linear(dim(2), max(0.25), min(-0.25)) GUIDE: axis(dim(1), label("Gemeinsame Variablen")) GUIDE: axis(dim(2), label("Korrelation")) ELEMENT: interval(position(gvar*dif), color(color.orange), color.saturation(absdiff)) ELEMENT: line(position(gvar*rez),label("Rezipienten"), color(color.red)) ELEMENT: line(position(gvar*don),label("Donoren"), color(color.blue)) PAGE: end() END GPL. |
|
Thanks ViAnn for your advice.
It's a shame that one can't change the backround via syntax. And replacing the quotes by !quote() didn't help to run the Macro. It's allways the same type of error. Here is a little bit smaller example: data list free /cat one. begin data 2 2 3 3 4 3 5 2 end data. GGRAPH /GRAPHDATASET NAME="graphdataset" VARIABLES= cat one /GRAPHSPEC SOURCE=INLINE. BEGIN GPL PAGE: begin(scale(1000px,700px)) SOURCE: s=userSource(id("graphdataset")) DATA: cat=col(source(s), name ("cat"), unit.category()) DATA: one=col(source(s), name ("one")) SCALE: linear(dim(2), max(4), min(1)) ELEMENT: line(position(cat*one), color(color.red)) PAGE: end() END GPL. define !gr () GGRAPH /GRAPHDATASET NAME=!quote(graphdataset) VARIABLES= cat one /GRAPHSPEC SOURCE=INLINE. BEGIN GPL PAGE: begin(scale(1000px,700px)) SOURCE: s=userSource(id(!quote(graphdataset))) DATA: cat=col(source(s), name (!quote(cat)), unit.category()) DATA: one=col(source(s), name (!quote(one))) SCALE: linear(dim(2), max(4), min(1)) ELEMENT: line(position(cat*one), color(color.red)) PAGE: end() END GPL. !enddefine. !gr. Maybe you or somebody can help me to run gpl inside of a macro. Thanks. Flo |
|
Hi Flo
you can actually change the background colour via syntax, admittedly not directly. For such cases I generate a template file open it with an editor and include the part I need in a WRITE OUTFILE command structure. I then use the template command for including the template in the chart. For example: data list free /cat one. begin data 2 2 3 3 4 3 5 2 end data. Do if $casenum = 1. WRITE OUTFILE='d:\temp\BackCol.sgt' /'<?xml version="1.0" encoding="UTF-8" standalone="no"?>' /'<template SPSS-Version="2.2" ' /' selectPath="12 " ' /' xmlns="http://xml.spss.com/spss/visualization" ' /' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' /' xsi:schemaLocation="http://xml.spss.com/spss/visualization ' /' http://xml.spss.com/spss/visualization/vizml-template-3.0.xsd">' /' <addFrame count="1" styleOnly="true" type="graph"> ' /' <style color="transparent" color2="transparent" visible="true"/> ' /' <style color="#f8981d" color2="#000000" number="1" visible="true"/> ' /' </addFrame> ' /'</template> '. End if. EXECUTE. You also could also change the template dynamically depending on your data. I posted a while ago a syntax that adds a reference line dynamically (depending on the data). Here the example: DATA LIST LIST /v1(F8) v2(F8) v3(F8). BEGIN DATA. 2 4 90 4 4 7 3 5 7 END DATA. compute meanvar_1=mean(v1 to v3). compute break = 1. AGGREGATE /OUTFILE=* MODE=ADDVARIABLES /BREAK=break /meanvar = MEAN(meanvar_1). * Write a template for the reference line. * The template is saved as: d:\temp\ReferenceLine.sgt. * The mean is written as meanvar (from the variabel meanvar) into the template. * The line style is set to red here. Do if $casenum = 1. WRITE OUTFILE='d:\temp\ReferenceLine.sgt' /'<?xml version="1.0" encoding="UTF-8" standalone="no"?>' /'<template SPSS-Version="2.2" ' /' selectPath="900 " ' /' xmlns="http://xml.spss.com/spss/visualization" ' /' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' /' xsi:schemaLocation="http://xml.spss.com/spss/visualization ' /' http://xml.spss.com/spss/visualization/vizml-template-3.0.xsd">' /' <addReferenceLine styleOnly="false" y=" ' /meanvar /' " ycategorical="false">' /' <style color="#f50000" visible="true"/>' /' </addReferenceLine>' /'</template>'. End if. EXECUTE. GGRAPH /GRAPHDATASET NAME="graphdataset" VARIABLES=v1 to v3 MISSING=LISTWISE REPORTMISSING=NO /GRAPHSPEC SOURCE=INLINE TEMPLATE=[ "D:\Temp\ReferenceLine.sgt"]. BEGIN GPL SOURCE: s=userSource(id("graphdataset")) DATA: v1=col(source(s), name("v1")) DATA: v2=col(source(s), name("v2")) DATA: v3=col(source(s), name("v3")) ELEMENT: interval(position(region.confi.mean( "v1" * v1 )), shape.interior(shape.ibeam) ) ELEMENT: interval(position(region.confi.mean( "v2" * v2 )), shape.interior(shape.ibeam) ) ELEMENT: interval(position(region.confi.mean( "v3" * v3 )), shape.interior(shape.ibeam) ) ELEMENT: point(position(summary.mean( "v1" * v1 )), color.interior(color.red) ) ELEMENT: point(position(summary.mean( "v2" * v2 )), color.interior(color.red) ) ELEMENT: point(position(summary.mean( "v3" * v3 )), color.interior(color.red) ) END GPL. Hope this helps Christian ******************************* la volta statistics Christian Schmidhauser, Dr.phil.II Weinbergstrasse 108 Ch-8006 Zürich Tel: +41 (043) 233 98 01 Fax: +41 (043) 233 98 02 email: mailto:[hidden email] internet: http://www.lavolta.ch/ -----Ursprüngliche Nachricht----- Von: SPSSX(r) Discussion [mailto:[hidden email]]Im Auftrag von flo statistik Gesendet: Freitag, 28. September 2007 13:18 An: [hidden email] Betreff: Fwd: GPL GGRAPH Thanks ViAnn for your advice. It's a shame that one can't change the backround via syntax. And replacing the quotes by !quote() didn't help to run the Macro. It's allways the same type of error. Here is a little bit smaller example: data list free /cat one. begin data 2 2 3 3 4 3 5 2 end data. GGRAPH /GRAPHDATASET NAME="graphdataset" VARIABLES= cat one /GRAPHSPEC SOURCE=INLINE. BEGIN GPL PAGE: begin(scale(1000px,700px)) SOURCE: s=userSource(id("graphdataset")) DATA: cat=col(source(s), name ("cat"), unit.category()) DATA: one=col(source(s), name ("one")) SCALE: linear(dim(2), max(4), min(1)) ELEMENT: line(position(cat*one), color(color.red)) PAGE: end() END GPL. define !gr () GGRAPH /GRAPHDATASET NAME=!quote(graphdataset) VARIABLES= cat one /GRAPHSPEC SOURCE=INLINE. BEGIN GPL PAGE: begin(scale(1000px,700px)) SOURCE: s=userSource(id(!quote(graphdataset))) DATA: cat=col(source(s), name (!quote(cat)), unit.category()) DATA: one=col(source(s), name (!quote(one))) SCALE: linear(dim(2), max(4), min(1)) ELEMENT: line(position(cat*one), color(color.red)) PAGE: end() END GPL. !enddefine. !gr. Maybe you or somebody can help me to run gpl inside of a macro. Thanks. Flo |
|
Hi Christian
This trick is absolutely great! (writing the chart template dinamically, I mean). Thanks for it, I have already adapted it for one of my MACROS. I love to keep on learning, and this list never dissapoints me! Best regards, Mart > Do if $casenum = 1. > WRITE OUTFILE='d:\temp\BackCol.sgt' > /'<?xml version="1.0" encoding="UTF-8" standalone="no"?>' > /'<template SPSS-Version="2.2" ' > /' selectPath="12 " ' > /' xmlns="http://xml.spss.com/spss/visualization" ' > /' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' > /' xsi:schemaLocation="http://xml.spss.com/spss/visualization ' > /' http://xml.spss.com/spss/visualization/vizml-template-3.0.xsd">' > /' <addFrame count="1" styleOnly="true" type="graph"> ' > /' <style color="transparent" color2="transparent" visible="true"/> ' > /' <style color="#f8981d" color2="#000000" number="1" visible="true"/> ' > /' </addFrame> ' > /'</template> '. > End if. > EXECUTE. > > You also could also change the template dynamically depending on your data. > I posted a while ago a syntax that adds a reference line dynamically > (depending on the data). > Here the example: > > DATA LIST LIST /v1(F8) v2(F8) v3(F8). > BEGIN DATA. > 2 4 90 > 4 4 7 > 3 5 7 > END DATA. > > compute meanvar_1=mean(v1 to v3). > compute break = 1. > > AGGREGATE > /OUTFILE=* > MODE=ADDVARIABLES > /BREAK=break > /meanvar = MEAN(meanvar_1). > > * Write a template for the reference line. > * The template is saved as: d:\temp\ReferenceLine.sgt. > * The mean is written as meanvar (from the variabel meanvar) into the > template. > * The line style is set to red here. > > Do if $casenum = 1. > WRITE OUTFILE='d:\temp\ReferenceLine.sgt' > /'<?xml version="1.0" encoding="UTF-8" standalone="no"?>' > /'<template SPSS-Version="2.2" ' > /' selectPath="900 " ' > /' xmlns="http://xml.spss.com/spss/visualization" ' > /' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' > /' xsi:schemaLocation="http://xml.spss.com/spss/visualization ' > /' http://xml.spss.com/spss/visualization/vizml-template-3.0.xsd">' > /' <addReferenceLine styleOnly="false" y=" ' > /meanvar > /' " ycategorical="false">' > /' <style color="#f50000" visible="true"/>' > /' </addReferenceLine>' > /'</template>'. > End if. > EXECUTE. > > GGRAPH > /GRAPHDATASET NAME="graphdataset" VARIABLES=v1 to v3 > MISSING=LISTWISE REPORTMISSING=NO > /GRAPHSPEC SOURCE=INLINE > TEMPLATE=[ > "D:\Temp\ReferenceLine.sgt"]. > BEGIN GPL > SOURCE: s=userSource(id("graphdataset")) > DATA: v1=col(source(s), name("v1")) > DATA: v2=col(source(s), name("v2")) > DATA: v3=col(source(s), name("v3")) > ELEMENT: interval(position(region.confi.mean( "v1" * v1 )), > shape.interior(shape.ibeam) ) > ELEMENT: interval(position(region.confi.mean( "v2" * v2 )), > shape.interior(shape.ibeam) ) > ELEMENT: interval(position(region.confi.mean( "v3" * v3 )), > shape.interior(shape.ibeam) ) > ELEMENT: point(position(summary.mean( "v1" * v1 )), > color.interior(color.red) ) > ELEMENT: point(position(summary.mean( "v2" * v2 )), > color.interior(color.red) ) > ELEMENT: point(position(summary.mean( "v3" * v3 )), > color.interior(color.red) ) > END GPL. > > Hope this helps > Christian > > ******************************* > la volta statistics > Christian Schmidhauser, Dr.phil.II > Weinbergstrasse 108 > Ch-8006 Zürich > Tel: +41 (043) 233 98 01 > Fax: +41 (043) 233 98 02 > email: mailto:[hidden email] > internet: http://www.lavolta.ch/ > > > -----Ursprüngliche Nachricht----- > Von: SPSSX(r) Discussion [mailto:[hidden email]]Im Auftrag von > flo statistik > Gesendet: Freitag, 28. September 2007 13:18 > An: [hidden email] > Betreff: Fwd: GPL GGRAPH > > > Thanks ViAnn for your advice. > > It's a shame that one can't change the backround via syntax. > > And replacing the quotes by !quote() didn't help to run the Macro. It's > allways the same type of error. > > Here is a little bit smaller example: > > > data list free /cat one. > begin data > 2 2 > 3 3 > 4 3 > 5 2 > end data. > > GGRAPH > /GRAPHDATASET NAME="graphdataset" VARIABLES= cat one > /GRAPHSPEC SOURCE=INLINE. > BEGIN GPL > PAGE: begin(scale(1000px,700px)) > SOURCE: s=userSource(id("graphdataset")) > DATA: cat=col(source(s), name ("cat"), unit.category()) > DATA: one=col(source(s), name ("one")) > SCALE: linear(dim(2), max(4), min(1)) > ELEMENT: line(position(cat*one), color(color.red)) > PAGE: end() > END GPL. > > > define !gr () > > GGRAPH > /GRAPHDATASET NAME=!quote(graphdataset) VARIABLES= cat one > /GRAPHSPEC SOURCE=INLINE. > BEGIN GPL > PAGE: begin(scale(1000px,700px)) > SOURCE: s=userSource(id(!quote(graphdataset))) > DATA: cat=col(source(s), name (!quote(cat)), unit.category()) > DATA: one=col(source(s), name (!quote(one))) > SCALE: linear(dim(2), max(4), min(1)) > ELEMENT: line(position(cat*one), color(color.red)) > PAGE: end() > END GPL. > > !enddefine. > > !gr. > Maybe you or somebody can help me to run gpl inside of a macro. > > Thanks. > > Flo > > |
|
Just an additioanl minor point:
To keep the hard disk clean, I add nomally an erase command after the chart. Here for example: Erase File= "D:\Temp\ReferenceLine.sgt". Christian -----Ursprüngliche Nachricht----- Von: SPSSX(r) Discussion [mailto:[hidden email]]Im Auftrag von Marta Garcia-Granero Gesendet: Montag, 1. Oktober 2007 14:11 An: [hidden email] Betreff: Re: AW: GPL GGRAPH Hi Christian This trick is absolutely great! (writing the chart template dinamically, I mean). Thanks for it, I have already adapted it for one of my MACROS. I love to keep on learning, and this list never dissapoints me! Best regards, Mart > Do if $casenum = 1. > WRITE OUTFILE='d:\temp\BackCol.sgt' > /'<?xml version="1.0" encoding="UTF-8" standalone="no"?>' > /'<template SPSS-Version="2.2" ' > /' selectPath="12 " ' > /' xmlns="http://xml.spss.com/spss/visualization" ' > /' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' > /' xsi:schemaLocation="http://xml.spss.com/spss/visualization ' > /' http://xml.spss.com/spss/visualization/vizml-template-3.0.xsd">' > /' <addFrame count="1" styleOnly="true" type="graph"> ' > /' <style color="transparent" color2="transparent" > /' <style color="#f8981d" color2="#000000" number="1" visible="true"/> ' > /' </addFrame> ' > /'</template> '. > End if. > EXECUTE. > > You also could also change the template dynamically depending on your data. > I posted a while ago a syntax that adds a reference line dynamically > (depending on the data). > Here the example: > > DATA LIST LIST /v1(F8) v2(F8) v3(F8). > BEGIN DATA. > 2 4 90 > 4 4 7 > 3 5 7 > END DATA. > > compute meanvar_1=mean(v1 to v3). > compute break = 1. > > AGGREGATE > /OUTFILE=* > MODE=ADDVARIABLES > /BREAK=break > /meanvar = MEAN(meanvar_1). > > * Write a template for the reference line. > * The template is saved as: d:\temp\ReferenceLine.sgt. > * The mean is written as meanvar (from the variabel meanvar) into the > template. > * The line style is set to red here. > > Do if $casenum = 1. > WRITE OUTFILE='d:\temp\ReferenceLine.sgt' > /'<?xml version="1.0" encoding="UTF-8" standalone="no"?>' > /'<template SPSS-Version="2.2" ' > /' selectPath="900 " ' > /' xmlns="http://xml.spss.com/spss/visualization" ' > /' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' > /' xsi:schemaLocation="http://xml.spss.com/spss/visualization ' > /' http://xml.spss.com/spss/visualization/vizml-template-3.0.xsd">' > /' <addReferenceLine styleOnly="false" y=" ' > /meanvar > /' " ycategorical="false">' > /' <style color="#f50000" visible="true"/>' > /' </addReferenceLine>' > /'</template>'. > End if. > EXECUTE. > > GGRAPH > /GRAPHDATASET NAME="graphdataset" VARIABLES=v1 to v3 > MISSING=LISTWISE REPORTMISSING=NO > /GRAPHSPEC SOURCE=INLINE > TEMPLATE=[ > "D:\Temp\ReferenceLine.sgt"]. > BEGIN GPL > SOURCE: s=userSource(id("graphdataset")) > DATA: v1=col(source(s), name("v1")) > DATA: v2=col(source(s), name("v2")) > DATA: v3=col(source(s), name("v3")) > ELEMENT: interval(position(region.confi.mean( "v1" * v1 )), > shape.interior(shape.ibeam) ) > ELEMENT: interval(position(region.confi.mean( "v2" * v2 )), > shape.interior(shape.ibeam) ) > ELEMENT: interval(position(region.confi.mean( "v3" * v3 )), > shape.interior(shape.ibeam) ) > ELEMENT: point(position(summary.mean( "v1" * v1 )), > color.interior(color.red) ) > ELEMENT: point(position(summary.mean( "v2" * v2 )), > color.interior(color.red) ) > ELEMENT: point(position(summary.mean( "v3" * v3 )), > color.interior(color.red) ) > END GPL. > > Hope this helps > Christian > > ******************************* > la volta statistics > Christian Schmidhauser, Dr.phil.II > Weinbergstrasse 108 > Ch-8006 Zürich > Tel: +41 (043) 233 98 01 > Fax: +41 (043) 233 98 02 > email: mailto:[hidden email] > internet: http://www.lavolta.ch/ > > > -----Ursprüngliche Nachricht----- > Von: SPSSX(r) Discussion [mailto:[hidden email]]Im Auftrag von > flo statistik > Gesendet: Freitag, 28. September 2007 13:18 > An: [hidden email] > Betreff: Fwd: GPL GGRAPH > > > Thanks ViAnn for your advice. > > It's a shame that one can't change the backround via syntax. > > And replacing the quotes by !quote() didn't help to run the Macro. It's > allways the same type of error. > > Here is a little bit smaller example: > > > data list free /cat one. > begin data > 2 2 > 3 3 > 4 3 > 5 2 > end data. > > GGRAPH > /GRAPHDATASET NAME="graphdataset" VARIABLES= cat one > /GRAPHSPEC SOURCE=INLINE. > BEGIN GPL > PAGE: begin(scale(1000px,700px)) > SOURCE: s=userSource(id("graphdataset")) > DATA: cat=col(source(s), name ("cat"), unit.category()) > DATA: one=col(source(s), name ("one")) > SCALE: linear(dim(2), max(4), min(1)) > ELEMENT: line(position(cat*one), color(color.red)) > PAGE: end() > END GPL. > > > define !gr () > > GGRAPH > /GRAPHDATASET NAME=!quote(graphdataset) VARIABLES= cat one > /GRAPHSPEC SOURCE=INLINE. > BEGIN GPL > PAGE: begin(scale(1000px,700px)) > SOURCE: s=userSource(id(!quote(graphdataset))) > DATA: cat=col(source(s), name (!quote(cat)), unit.category()) > DATA: one=col(source(s), name (!quote(one))) > SCALE: linear(dim(2), max(4), min(1)) > ELEMENT: line(position(cat*one), color(color.red)) > PAGE: end() > END GPL. > > !enddefine. > > !gr. > Maybe you or somebody can help me to run gpl inside of a macro. > > Thanks. > > Flo > > |
|
In reply to this post by Marta Garcia-Granero
Yes, it is a good trick. Unfortunately, it requires some knowledge of what a
template does and AFAIK the chart template is undocumented. A template is a fragment of a chart which modifies the vizML which is the XML definition of the chart. Note that you can get the schema from xml.spss.com/spss/visualization and you can also save chart xml from the editor if you want to experiment with vizml. There are also some hand-crafted templates on the SPSS site which can add special effects to the chart that aren't available otherwise. Go to http://support.spss.com/Tech/Products/SPSS/Utilities/SPSSforWindows/template s/index.html and take a look. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Marta Garcia-Granero Sent: Monday, October 01, 2007 6:11 AM To: [hidden email] Subject: Re: AW: GPL GGRAPH Hi Christian This trick is absolutely great! (writing the chart template dinamically, I mean). Thanks for it, I have already adapted it for one of my MACROS. I love to keep on learning, and this list never dissapoints me! Best regards, Mart > Do if $casenum = 1. > WRITE OUTFILE='d:\temp\BackCol.sgt' > /'<?xml version="1.0" encoding="UTF-8" standalone="no"?>' > /'<template SPSS-Version="2.2" ' > /' selectPath="12 " ' > /' xmlns="http://xml.spss.com/spss/visualization" ' > /' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' > /' xsi:schemaLocation="http://xml.spss.com/spss/visualization ' > /' http://xml.spss.com/spss/visualization/vizml-template-3.0.xsd">' > /' <addFrame count="1" styleOnly="true" type="graph"> ' > /' <style color="transparent" color2="transparent" > /' <style color="#f8981d" color2="#000000" number="1" visible="true"/> ' > /' </addFrame> ' > /'</template> '. > End if. > EXECUTE. > > You also could also change the template dynamically depending on your data. > I posted a while ago a syntax that adds a reference line dynamically > (depending on the data). > Here the example: > > DATA LIST LIST /v1(F8) v2(F8) v3(F8). > BEGIN DATA. > 2 4 90 > 4 4 7 > 3 5 7 > END DATA. > > compute meanvar_1=mean(v1 to v3). > compute break = 1. > > AGGREGATE > /OUTFILE=* > MODE=ADDVARIABLES > /BREAK=break > /meanvar = MEAN(meanvar_1). > > * Write a template for the reference line. > * The template is saved as: d:\temp\ReferenceLine.sgt. > * The mean is written as meanvar (from the variabel meanvar) into the > template. > * The line style is set to red here. > > Do if $casenum = 1. > WRITE OUTFILE='d:\temp\ReferenceLine.sgt' > /'<?xml version="1.0" encoding="UTF-8" standalone="no"?>' > /'<template SPSS-Version="2.2" ' > /' selectPath="900 " ' > /' xmlns="http://xml.spss.com/spss/visualization" ' > /' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' > /' xsi:schemaLocation="http://xml.spss.com/spss/visualization ' > /' http://xml.spss.com/spss/visualization/vizml-template-3.0.xsd">' > /' <addReferenceLine styleOnly="false" y=" ' > /meanvar > /' " ycategorical="false">' > /' <style color="#f50000" visible="true"/>' > /' </addReferenceLine>' > /'</template>'. > End if. > EXECUTE. > > GGRAPH > /GRAPHDATASET NAME="graphdataset" VARIABLES=v1 to v3 > MISSING=LISTWISE REPORTMISSING=NO > /GRAPHSPEC SOURCE=INLINE > TEMPLATE=[ > "D:\Temp\ReferenceLine.sgt"]. > BEGIN GPL > SOURCE: s=userSource(id("graphdataset")) > DATA: v1=col(source(s), name("v1")) > DATA: v2=col(source(s), name("v2")) > DATA: v3=col(source(s), name("v3")) > ELEMENT: interval(position(region.confi.mean( "v1" * v1 )), > shape.interior(shape.ibeam) ) > ELEMENT: interval(position(region.confi.mean( "v2" * v2 )), > shape.interior(shape.ibeam) ) > ELEMENT: interval(position(region.confi.mean( "v3" * v3 )), > shape.interior(shape.ibeam) ) > ELEMENT: point(position(summary.mean( "v1" * v1 )), > color.interior(color.red) ) > ELEMENT: point(position(summary.mean( "v2" * v2 )), > color.interior(color.red) ) > ELEMENT: point(position(summary.mean( "v3" * v3 )), > color.interior(color.red) ) > END GPL. > > Hope this helps > Christian > > |
| Free forum by Nabble | Edit this page |
