Pattern in GGRAPH bar chart?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Pattern in GGRAPH bar chart?

Robert L

I have got this simple bar chart with stacked bars, two fields for each x-axis category, and I would like to have a pattern in each part of the bars. If texture.pattern(cat_var) is added to the ELEMENT part of the GGRAPH syntax, only one of the parts is patterned. Any suggestions for adding patterns to all parts (naturally with the same pattern sequence for each x-axis category)? How could I control which part gets a specific pattern?

 

Robert

Robert Lundqvist
Reply | Threaded
Open this post in threaded view
|

Re: Pattern in GGRAPH bar chart?

Andy W
You seem to be talking about the fact that the first default pattern in the cycled set of patterns is solid. Below is an example of mapping a set of specific patterns.

*******************************************.
DATA LIST FREE / X Val Stack Pattern.
BEGIN DATA
1 4 1 1
1 8 2 1
2 9 1 2
2 2 2 2
END DATA.
FORMATS ALL (F1.0).

GGRAPH
  /GRAPHDATASET NAME="graphdataset" VARIABLES=X Val Stack Pattern
  /GRAPHSPEC SOURCE=INLINE.
BEGIN GPL
  SOURCE: s=userSource(id("graphdataset"))
  DATA: X=col(source(s), name("X"), unit.category())
  DATA: Val=col(source(s), name("Val"))
  DATA: Stack=col(source(s), name("Stack"), unit.category())
  DATA: Pattern=col(source(s), name("Pattern"), unit.category())
  GUIDE: axis(dim(1), label("X"))
  GUIDE: axis(dim(2), label("Val"))
  GUIDE: legend(aesthetic(aesthetic.color.interior), label("Stack"))
  GUIDE: legend(aesthetic(aesthetic.texture.pattern), label("Pattern"))
  SCALE: cat(aesthetic(aesthetic.texture.pattern), map(("1",texture.pattern.checkered),("2",texture.pattern.mesh)))
  SCALE: linear(dim(2), include(0))
  ELEMENT: interval.stack(position(X*Val), color.interior(Stack), texture.pattern(Pattern))
END GPL.
*******************************************.

Which produced the below image.



Check out the [SCALE: cat] line - as that is what defines the patterns used. If you took this out, the left bar would be a solid fill. A way to permanently change this behavior with the default graph is in the menus go to

Edit -> Options -> Charts (tab) -> Fills (in Style Cycles)

There you will see the default fill is blank - you can set this to something else. You can also edit the cycles in the chart template as well.

Andy W
apwheele@gmail.com
http://andrewpwheeler.wordpress.com/
Reply | Threaded
Open this post in threaded view
|

Re: Pattern in GGRAPH bar chart?

Jon K Peck
In reply to this post by Robert L
Remember that you can simply set your preferences via Edit > Options > Charts to "Cycle through patterns only" to get patterned charts.


Jon Peck (no "h") aka Kim
Senior Software Engineer, IBM
[hidden email]
phone: 720-342-5621




From:        Robert Lundqvist <[hidden email]>
To:        [hidden email],
Date:        02/21/2014 12:57 AM
Subject:        [SPSSX-L] Pattern in GGRAPH bar chart?
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




I have got this simple bar chart with stacked bars, two fields for each x-axis category, and I would like to have a pattern in each part of the bars. If texture.pattern(cat_var) is added to the ELEMENT part of the GGRAPH syntax, only one of the parts is patterned. Any suggestions for adding patterns to all parts (naturally with the same pattern sequence for each x-axis category)? How could I control which part gets a specific pattern?
 
Robert
Reply | Threaded
Open this post in threaded view
|

SV: Pattern in GGRAPH bar chart?

Robert L
In reply to this post by Andy W
Hi Andy,

many thanks for your solution, of course it works just fine. But it got even closer to what I had in mind with texture.pattern(Stack) rather than texture.pattern(Pattern). That makes each pattern correspond to a specific colour, which results in a quite reasonable printout on a black-and-white printer. Thanks again, I don't think I would have started to look at the SCALE(cat(...)) without your help here.

Robert

-----Ursprungligt meddelande-----
Från: SPSSX(r) Discussion [mailto:[hidden email]] För Andy W
Skickat: den 21 februari 2014 14:06
Till: [hidden email]
Ämne: Re: Pattern in GGRAPH bar chart?

You seem to be talking about the fact that the first default pattern in the cycled set of patterns is solid. Below is an example of mapping a set of specific patterns.

*******************************************.
DATA LIST FREE / X Val Stack Pattern.
BEGIN DATA
1 4 1 1
1 8 2 1
2 9 1 2
2 2 2 2
END DATA.
FORMATS ALL (F1.0).

GGRAPH
  /GRAPHDATASET NAME="graphdataset" VARIABLES=X Val Stack Pattern
  /GRAPHSPEC SOURCE=INLINE.
BEGIN GPL
  SOURCE: s=userSource(id("graphdataset"))
  DATA: X=col(source(s), name("X"), unit.category())
  DATA: Val=col(source(s), name("Val"))
  DATA: Stack=col(source(s), name("Stack"), unit.category())
  DATA: Pattern=col(source(s), name("Pattern"), unit.category())
  GUIDE: axis(dim(1), label("X"))
  GUIDE: axis(dim(2), label("Val"))
  GUIDE: legend(aesthetic(aesthetic.color.interior), label("Stack"))
  GUIDE: legend(aesthetic(aesthetic.texture.pattern), label("Pattern"))
  SCALE: cat(aesthetic(aesthetic.texture.pattern),
map(("1",texture.pattern.checkered),("2",texture.pattern.mesh)))
  SCALE: linear(dim(2), include(0))
  ELEMENT: interval.stack(position(X*Val), color.interior(Stack),
texture.pattern(Pattern))
END GPL.
*******************************************.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Robert Lundqvist