在 SPSS 中用虚线在折线图上应用模板

Apply Template on line diagram with dashed lines in SPSS

我使用 SPSS 中的图表生成器创建了一个包含多条线的折线图。 在图表编辑器中,我将线条样式从 "color" 更改为 "dash"。我将样式另存为模板,以将其应用于更多类似的折线图。但是模板似乎没有应用,线条仍然是彩色的而不是虚线。

有没有办法在语法中告诉 SPSS 从模板应用虚线样式?

是的,您必须在 GPL 声明中告诉 SPSS 您要使用虚线样式。

因此,假设您从 'breakfast.sav' 示例文件创建了以下图表:

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.

现在,在 ELEMENT 语句中,您需要将两个 color.interior 函数更改为 shape.interior。所以声明看起来像这样。

  ELEMENT: line(position(summary.percent(BT*COUNT, 
           base.aesthetic(aesthetic(aesthetic.shape.interior)))), 
           shape.interior(gender), missing.wings()) 

这会将彩色线条变成黑色虚线。

如果您想要彩色和虚线,只需将 shape.interior(gender) 函数添加到现有的 ELEMENT 语句:

  ELEMENT: line(position(summary.percent(BT*COUNT, 
           base.aesthetic(aesthetic(aesthetic.color.interior)))), 
           color.interior(gender), shape.interior(gender), missing.wings()) 

我认为重点是添加这些设置。但是,如果您不想要它们,只需删除美学、颜色和形状函数引用即可。