Excellent, glad you were able to figure it out Alexander.
For anyone else who wonders what the difference is:
This:
DATA: Training_type=col(source(s), name("age"), unit.category())
versus this:
DATA: Training_type=col(source(s), name("Training_type"), unit.category())
The "Training_type" variable was needed where previously there was "age".
------------------------------
Curtis Browning
SPSS Statistics Architect
------------------------------
Original Message:
Sent: Sun October 17, 2021 04:04 AM
From: Alexander Farr
Subject: Two box plots in one figure: Empty graph
I found the bug, this one works:
DATASET ACTIVATE DataSet1.USE ALL.EXECUTE.DATASET ACTIVATE DataSet1./*Boxplot for age, both should be next to each other* Chart Builder.GGRAPH /GRAPHDATASET NAME="graphdataset" VARIABLES=Training_type Age MISSING=LISTWISE REPORTMISSING=NO /GRAPHSPEC SOURCE=INLINE.BEGIN GPL SOURCE: s=userSource(id("graphdataset")) DATA: Training_type=col(source(s), name("Training_type"), unit.category()) DATA: Age=col(source(s), name("Age")) DATA: id=col(source(s), name("$CASENUM"), unit.category()) GUIDE: axis(dim(1), label("Training_type")) GUIDE: axis(dim(2), label("Age")) GUIDE: text.title(label("Simple Boxplot of Age by treatment group")) SCALE: linear(dim(2), include(0)) ELEMENT: schema(position(bin.quantile.letter(Training_type*Age)), label(id))END GPL.
------------------------------
Alexander Farr
Original Message:
Sent: Sun October 17, 2021 03:58 AM
From: Alexander Farr
Subject: Two box plots in one figure: Empty graph
Dear community,
I want to run one graph with two boxplots. Based on an example, that works, I wrote the following script:
DATASET ACTIVATE DataSet1.
USE ALL.
EXECUTE.
DATASET ACTIVATE DataSet1.
* Chart Builder.
GGRAPH
/GRAPHDATASET NAME="graphdataset" VARIABLES=age MISSING=LISTWISE REPORTMISSING=NO
/GRAPHSPEC SOURCE=INLINE.
BEGIN GPL
SOURCE: s=userSource(id("graphdataset"))
DATA: Training_type=col(source(s), name("age"), unit.category())
DATA: Age=col(source(s), name("Age"))
DATA: id=col(source(s), name("$CASENUM"), unit.category())
GUIDE: axis(dim(1), label("Training_type"))
GUIDE: axis(dim(2), label("Age"))
GUIDE: text.title(label("Simple Boxplot of Age by treatment group"))
SCALE: linear(dim(2), include(0))
ELEMENT: schema(position(bin.quantile.letter(Training_type*Age)), label(id))
END GPL.
However, the resulting script looks as follows:
This is especially surprising since the code with the same structure works for a different variable and for separate box plots for each treatment group. I assume that the problem might be related to the scale 16-60 at the bottom which should rather refer to age than training_type. But I cannot identify why the axes might be switched.
Thank you very much in advance for your help!
------------------------------
Alexander Farr
------------------------------
#SPSSStatistics