How to create a pie chart with color and pattern i

2019-08-17 06:47发布

问题:

I want to create a colored and additional pattern, pie chart with GGRAPH\GPL. The function of the pattern is to visualize the major category to which the respective category belongs to.

With the SPSS Chart Builder I can only create a colored or a patterned pie chart.

The relevant ELEMENT Statement looks as follows:

ELEMENT: interval.stack(position(summary.percent(COUNT))), color(myvar))

Or:

ELEMENT: interval.stack(position(summary.percent(COUNT))), texture.pattern(myvar))

回答1:

Taking the Syntax created for the colored pie chart you can add the texture by simply adding the texture.pattern(myVar) function into the Element statement:

  ELEMENT: interval.stack(position(summary.percent(COUNT))), color(krwirtsek_kombi), texture.pattern(krwirtsek_kombi))

You can specify the color and pattern by using a template or via the map-function inside the scale statment:

SCALE: cat(aesthetic(aesthetic.color.interior), map(("<catvalue>", color."<rgb>"),  ...)
SCALE: cat(aesthetic(aesthetic.texture.pattern), map(("<catvalue>", texture.pattern.<patternconstant>), ...)

However when combining the color() and the texture.pattern() functions in the ELEMENT Statement and the tinkering with oder GPL-funtions, the results of these other functions might get odd (see this question about category order).