I created a line diagram with multiple lines with the Chart Builder in SPSS. Within the Chart Editor I changed the line style from "color" to "dash". I saved the style as a template to apply it to further similar line charts. However the template doesn't seem to be applied, the lines are still colored and not dashed.
Is there a way to tell SPSS in the Syntax to apply a dashed line style from template?
Yes, you have to tell SPSS inside the GPL statement that you want to use a dashed style.
So lets assume you created the following chart from the 'breakfast.sav' sample file:
GGRAPH
/GRAPHDATASET NAME="graphdataset" VARIABLES=BT COUNT()[name="COUNT"]
gender[LEVEL=NOMINAL] MISSING=LISTWISE REPORTMISSING=NO
/GRAPHSPEC SOURCE=INLINE TEMPLATE = "$HOME/SPSS/linediagram.sgt".
BEGIN GPL
SOURCE: s=userSource(id("graphdataset"))
DATA: BT=col(source(s), name("BT"), unit.category())
DATA: COUNT=col(source(s), name("COUNT"))
DATA: gender=col(source(s), name("gender"), unit.category())
GUIDE: axis(dim(1), label("Buttered toast"))
GUIDE: axis(dim(2), label("Percent"))
GUIDE: legend(aesthetic(aesthetic.color.interior), label("Gender"))
SCALE: linear(dim(2), include(0))
SCALE: cat(aesthetic(aesthetic.color.interior), include("1", "2"))
ELEMENT: line(position(summary.percent(BT*COUNT,
base.aesthetic(aesthetic(aesthetic.color.interior)))),
color.interior(gender), missing.wings())
END GPL.
Now within the ELEMENT
statement you need to change both color.interior
functions into shape.interior
. So the statement would look like this.
ELEMENT: line(position(summary.percent(BT*COUNT,
base.aesthetic(aesthetic(aesthetic.shape.interior)))),
shape.interior(gender), missing.wings())
This turns the colored lines into black dashed lines.
If you want colored and dashed lines, just add the shape.interior(gender)
function to the existing ELEMENT statement:
ELEMENT: line(position(summary.percent(BT*COUNT,
base.aesthetic(aesthetic(aesthetic.color.interior)))),
color.interior(gender), shape.interior(gender), missing.wings())