Specific Bar Color Change Via Syntax

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

Specific Bar Color Change Via Syntax

Rajeshms
Hi All,

I want to change a particular bar color in a simple bar graph via spss syntax. Is this possible. ?

I strongly feel it can be. But I am not able to get that, I did lots of research on this. Can anyone help me getting this. 

Thanks all.

Regards,

Rajesh M S




===================== 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
Reply | Threaded
Open this post in threaded view
|

Re: Specific Bar Color Change Via Syntax

Andy W
Here is an example below. Paste the syntax for whatever bar chart you are making (using the Chart Builder). Then in the ELEMENT line, put

, color.interior(<Your X Variable>)

This will color all the bars different colors. To make one a specific color and the rest the same, see the SCALE: cat line. Since the bars already have labels, I also suppress the superfluous legend in the GUIDE: legend line.


*************************************************************.
DATA LIST FREE / Cat (A1).
BEGIN DATA
A A A B B C
END DATA.
DATASET NAME Bars.

*Pasted graph output.
GGRAPH
  /GRAPHDATASET NAME="graphdataset" VARIABLES=Cat COUNT()[name="COUNT"] MISSING=LISTWISE
    REPORTMISSING=NO
  /GRAPHSPEC SOURCE=INLINE.
BEGIN GPL
  SOURCE: s=userSource(id("graphdataset"))
  DATA: Cat=col(source(s), name("Cat"), unit.category())
  DATA: COUNT=col(source(s), name("COUNT"))
  GUIDE: axis(dim(1), label("Cat"))
  GUIDE: axis(dim(2), label("Count"))
  SCALE: linear(dim(2), include(0))
  ELEMENT: interval(position(Cat*COUNT), shape.interior(shape.square))
END GPL.

GGRAPH
  /GRAPHDATASET NAME="graphdataset" VARIABLES=Cat COUNT()[name="COUNT"] MISSING=LISTWISE
    REPORTMISSING=NO
  /GRAPHSPEC SOURCE=INLINE.
BEGIN GPL
  SOURCE: s=userSource(id("graphdataset"))
  DATA: Cat=col(source(s), name("Cat"), unit.category())
  DATA: COUNT=col(source(s), name("COUNT"))
  GUIDE: axis(dim(1), label("Cat"))
  GUIDE: axis(dim(2), label("Count"))
  GUIDE: legend(aesthetic(aesthetic.color), null())
  SCALE: linear(dim(2), include(0))
  SCALE: cat(aesthetic(aesthetic.color), map(("A",color.red),("B",color.grey),("C",color.grey)))
  ELEMENT: interval(position(Cat*COUNT), shape.interior(shape.square), color.interior(Cat))
END GPL.
*************************************************************.
Andy W
apwheele@gmail.com
http://andrewpwheeler.wordpress.com/