You have to make that template, but using it is really just a simple command line.
--
Original Message:
Sent: 7/25/2024 6:40:00 AM
From: Moritz Schmid
Subject: RE: Using syntax to lable data during graph generation?
Hello Curtis,
I see. Thank you very much. I had hoped there was a simple command line I can use, but alas.Maybe something for a future edition...
Then templates it is!
Cheers
Moritz
------------------------------
Moritz Schmid
------------------------------
Original Message:
Sent: Wed July 24, 2024 12:20 PM
From: Curtis Browning
Subject: Using syntax to lable data during graph generation?
Hi @Moritz Schmid, I think I can help with this.
For your first question, you can generate a chart template from the Chart Editor that contains value labels as you would like them to appear. First generate the chart manually and setup your value labels. Then from the File menu in the Chart Editor, select the "Save Chart Template..." menu item, and save your template with the attributes you want in your new charts (Data Value Labels, etc).
Then, in your GGRAPH GPL you can generate something like this. Note the part highlighted in yellow:
* Chart Builder.
GGRAPH
/GRAPHDATASET NAME="graphdataset" VARIABLES=educ COUNT()[name="COUNT"] MISSING=LISTWISE
REPORTMISSING=NO
/GRAPHSPEC SOURCE=INLINE
TEMPLATE=["/Users/curtisbrowning/Downloads/chart-labels.sgt"].
BEGIN GPL
SOURCE: s=userSource(id("graphdataset"))
DATA: educ=col(source(s), name("educ"), unit.category())
DATA: COUNT=col(source(s), name("COUNT"))
GUIDE: axis(dim(1), label("Educational Level (years)"))
GUIDE: axis(dim(2), label("Count"))
GUIDE: text.title(label("Simple Bar Count of Educational Level (years)"))
SCALE: linear(dim(2), include(0))
ELEMENT: interval(position(educ*COUNT), shape.interior(shape.square))
END GPL.
In the example above I added the TEMPLATE keyword, which can be used to add chart attributes out of the box. I tested this and it works for Data Value Labels.
To label with different category names, I think you need a duplicate variable that contains translated English value labels. All else can be the same as your original German language variable, just the categorical value labels need to be different.
HTH,
------------------------------
Curtis Browning
SPSS Statistics Architect
Original Message:
Sent: Tue July 23, 2024 05:52 AM
From: Moritz Schmid
Subject: Using syntax to lable data during graph generation?
Hello!
I was wondering if there was a syntax command for ggraph so that the data labels are already activated (and formatted) when the graph is generated.
I have a lot of different graphs (mostly bar-charts and histograms) and would like to have the different bars/columns labeled while generating the graph. Nothing fancy, just the (in my case) percentage numbers.
I know I can "open" the graph after generation and enable them manually. However, I have hoped for syntax command along the lines of the GUIDE:-command for labeling titles etc. Best case scenario, this would let me edit position etc. as well.
A follow up question: is there a syntax to label the whole bars with different category names? Basically overwrite what SPSS draws from the variable description, as my data is labled in german, i plan to publish in english, though.
I have been searching the web as well as the forums but didn't find a solution - and am kinda surprised that this question isn't already answered (or I missed it).
Cheers and thank you for your help,
Moritz
------------------------------
Moritz Schmid
------------------------------