*This is the syntax exactly as it was used to create the graph. The graph was subsequently edited with the usual SPSS editing options.
*To ensure that the syntax works for you, check whether SPSS labeled the WDI2011 dataset as "DataSet1" when you opened it. If it didn't, adjust the dataset name in the syntax accordingly.
*Once you have done that, mark all of the syntax code and press the play ('run selection') button.
*If you want to use the syntax for different datasets and/or variables, you need to replace the dataset name and variable names in the code accordingly.
GGRAPH
  /GRAPHDATASET NAME="DataSet1" VARIABLES=CO2 gdp_groups MISSING=LISTWISE REPORTMISSING=NO
  /GRAPHSPEC SOURCE=INLINE.
BEGIN GPL
  SOURCE: s=userSource(id("DataSet1"))
  DATA: CO2=col(source(s), name("CO2"))
  DATA: gdp_groups=col(source(s), name("gdp_groups"), unit.category())
  GUIDE: axis(dim(1), label("CO2 emissions (metric tons per capita in 2010)"))
  GUIDE: axis(dim(2), label("Kernel Density Estimate"))
  GUIDE: legend(aesthetic(aesthetic.color.interior))
  SCALE: cat(aesthetic(aesthetic.color.interior), include("1", "2"))
  ELEMENT: line(position(density.kernel.epanechnikov(CO2*gdp_groups)), color(gdp_groups))
END GPL.