GPL vs IGRAPH: another issue

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

GPL vs IGRAPH: another issue

Luca Meyer
I am trying to do some bar chart starting from the following data:

DATA LIST LIST /ETICHETTA (A15) VAR2.
BEGIN DATA
CONOSCENZA 191
UTILIZZO 108
RIUTILIZZO 94
END DATA.

The matter is that when I use GPL the distance from the top of each of the 3
bars is not proportional to the numbers they represent.

This is the syntax I use for the GPL solution:

WEIGHT BY VAR2.
GGRAPH
  /GRAPHDATASET NAME="graphdataset" VARIABLES=ETICHETTA Var2
MISSING=LISTWISE REPORTMISSING=NO
  /GRAPHSPEC SOURCE=INLINE.
BEGIN GPL
 SOURCE: s=userSource(id("graphdataset"))
 DATA: ETICHETTA=col(source(s), name("ETICHETTA"), unit.category())
 DATA: Var2=col(source(s), name("Var2"), unit.category())
 GUIDE: axis(dim(1))
 GUIDE: axis(dim(2), label("Var2"))
 SCALE: cat(dim(1))
 SCALE: cat(dim(2))
 ELEMENT: interval(position(ETICHETTA*Var2), shape.interior(shape.square))
END GPL.

And here you can find the resulting graph: HYPERLINK
"http://www.lucameyer.com/CHART1.HTM"http://www.lucameyer.com/CHART1.HTM

Less good looking but more correct is the graph I obtain using IGRAPH:

WEIGHT BY VAR2.
IGRAPH
 /VIEWNAME='1240 CONOSCENZA -- UTILIZZO -- RIUTILIZZO'
 /X1 = VAR(ETICHETTA) TYPE = CATEGORICAL
 /Y = $count
 /COORDINATE = VERTICAL
 /X1LENGTH=6.0
 /YLENGTH=6.0
 /X2LENGTH=6.0
  /CHARTLOOK='NONE'
 /CATORDER VAR(ETICHETTA) (ASCENDING VALUES OMITEMPTY)
 /BAR KEY=OFF LABEL INSIDE VAL  SHAPE = RECTANGLE BASELINE = AUTO.

See here for the corresponding graph in which the proportions between bars
is respected (even though bar order and other formatting is not respected):
HYPERLINK
"http://www.lucameyer.com/CHART2.HTM"http://www.lucameyer.com/CHART2.HTM

Can anyone explain why this is the case?

Thanks,

Luca

Mr. Luca MEYER
Market research, data analysis & more
HYPERLINK "http://www.lucameyer.com/"www.lucameyer.com - Tel:
+39.339.495.00.21


No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.476 / Virus Database: 269.11.8/941 - Release Date: 07/08/2007
16.06
Reply | Threaded
Open this post in threaded view
|

Re: GPL vs IGRAPH: another issue

ViAnn Beadle
Wrong GPL syntax. You have just crossed ETICHETTA and VAR2. Given your
weight command, and using Chart Builder, you just need the y to be the
count:

GGRAPH
  /GRAPHDATASET NAME="graphdataset" VARIABLES=ETICHETTA COUNT()[name=
  "COUNT"] MISSING=LISTWISE REPORTMISSING=NO
  /GRAPHSPEC SOURCE=INLINE.
BEGIN GPL
 SOURCE: s=userSource(id("graphdataset"))
 DATA: ETICHETTA=col(source(s), name("ETICHETTA"), unit.category())
 DATA: COUNT=col(source(s), name("COUNT"))
 GUIDE: axis(dim(1), label("ETICHETTA"))
 GUIDE: axis(dim(2), label("Count"))
 SCALE: cat(dim(1))
 SCALE: linear(dim(2), include(0))
 ELEMENT: interval(position(ETICHETTA*COUNT), shape.interior(shape.square)
  )
END GPL.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Luca Meyer
Sent: Wednesday, August 08, 2007 8:03 AM
To: [hidden email]
Subject: GPL vs IGRAPH: another issue

I am trying to do some bar chart starting from the following data:

DATA LIST LIST /ETICHETTA (A15) VAR2.
BEGIN DATA
CONOSCENZA 191
UTILIZZO 108
RIUTILIZZO 94
END DATA.

The matter is that when I use GPL the distance from the top of each of the 3
bars is not proportional to the numbers they represent.

This is the syntax I use for the GPL solution:

WEIGHT BY VAR2.
GGRAPH
  /GRAPHDATASET NAME="graphdataset" VARIABLES=ETICHETTA Var2
MISSING=LISTWISE REPORTMISSING=NO
  /GRAPHSPEC SOURCE=INLINE.
BEGIN GPL
 SOURCE: s=userSource(id("graphdataset"))
 DATA: ETICHETTA=col(source(s), name("ETICHETTA"), unit.category())
 DATA: Var2=col(source(s), name("Var2"), unit.category())
 GUIDE: axis(dim(1))
 GUIDE: axis(dim(2), label("Var2"))
 SCALE: cat(dim(1))
 SCALE: cat(dim(2))
 ELEMENT: interval(position(ETICHETTA*Var2), shape.interior(shape.square))
END GPL.

And here you can find the resulting graph: HYPERLINK
"http://www.lucameyer.com/CHART1.HTM"http://www.lucameyer.com/CHART1.HTM

Less good looking but more correct is the graph I obtain using IGRAPH:

WEIGHT BY VAR2.
IGRAPH
 /VIEWNAME='1240 CONOSCENZA -- UTILIZZO -- RIUTILIZZO'
 /X1 = VAR(ETICHETTA) TYPE = CATEGORICAL
 /Y = $count
 /COORDINATE = VERTICAL
 /X1LENGTH=6.0
 /YLENGTH=6.0
 /X2LENGTH=6.0
  /CHARTLOOK='NONE'
 /CATORDER VAR(ETICHETTA) (ASCENDING VALUES OMITEMPTY)
 /BAR KEY=OFF LABEL INSIDE VAL  SHAPE = RECTANGLE BASELINE = AUTO.

See here for the corresponding graph in which the proportions between bars
is respected (even though bar order and other formatting is not respected):
HYPERLINK
"http://www.lucameyer.com/CHART2.HTM"http://www.lucameyer.com/CHART2.HTM

Can anyone explain why this is the case?

Thanks,

Luca

Mr. Luca MEYER
Market research, data analysis & more
HYPERLINK "http://www.lucameyer.com/"www.lucameyer.com - Tel:
+39.339.495.00.21


No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.476 / Virus Database: 269.11.8/941 - Release Date: 07/08/2007
16.06