Hello,
I wanted to change the colour of the bars in a bar graph via syntax. It can be done via clicking on the bars, but I don't want to have to do this each time I create a graph and my clumsiness has resulted in sometimes a single bar's colour being changed and then the background. I'm also interested in whether there is a SPSS manual for creating graphs? The following is v21 syntax. Thanks in advance, Bob GGRAPH /GRAPHDATASET NAME="graphdataset" VARIABLES=LSPtot COUNT()[name="COUNT"] MISSING=LISTWISE REPORTMISSING=NO /GRAPHSPEC SOURCE=INLINE. BEGIN GPL SOURCE: s=userSource(id("graphdataset")) DATA: LSPtot=col(source(s), name("LSPtot"), unit.category()) DATA: COUNT=col(source(s), name("COUNT")) GUIDE: axis(dim(1), label("Compliance subscale score")) GUIDE: axis(dim(2), label("Number of patients"), delta(50)) SCALE: linear(dim(2), include(0)) ELEMENT: interval(position(LSPtot*COUNT), shape.interior(shape.square)) 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 |
This question comes up fairly often but has a complicated answer. I could
give you the simple answer here if I knew what color you want and under what circumstances you want it. There are many ways to generate a chart but they come down to two paths: 1. GPL via Chart Builder, GGRAPH, or charts built into procedures. Many ways to create it and one way to edit the resulting chart via the chart editor. 2. Graphboard Template Chooser: One way to create it and one way to edit via the Graphboard Editor. GPL: When you create a bar graph via Chart Builder, it is generating GPL (the stuff between BEGIN GPL and END GPL). Or you can type in your own syntax using the GGRAPH command and GPL. GPL provides some basic functions which can be used to control aesthetics like color, font, transparency, symbols, etc. Of the these functions is the color function. So to change your bars, you could use the color function and specify a color or RGB values. For example, you could use color(color.blue) in the ELEMENT statement. Now color.blue is a constant. If you look at Help > GPL Reference > GPL Statement and Function Reference > GPL Functions you will find the color function and if you look at Help > GPL Reference > GPL Constants you will find all the color constants. You could instead, specify a hex value in quotation marks if you have to know the rgb values. Templates: When you use the chart editor to change the color of a set of bars (which you note that you have done), you can also save a template within the chart editor and then make that the template you use in Chart Builder or via the GGRAPH command using the TEMPLATE keyword. Once you have saved this template, you name it via Chart Builder>Options. Built-in Templates: If you always want the same color used for bars, fills, and lines in your charts, you can control that in a template to be applied to almost any chart in Edit>Options. Click on the Charts Tab, and then click on the Colors sub tab. Your chart example here is an ungrouped chart, but you can also set a color cycle for grouped or stacked chart via this user interface. This becomes your default template to be applied to most all charts. Graphboard Template Chooser: If you create a chart via this command, you have a completely different set of options and I'll defer that discussion for now. This is one complicated mess and a function of incrementally providing more formatting control in Graphics over a 20 year time period. There are lots of twisty passages in the formatting cave that kinda look alike but are different (apologies to Adventure). -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Bob Green Sent: Tuesday, September 17, 2013 5:54 PM To: [hidden email] Subject: Changing colour in a bar graph via syntax & manual info Hello, I wanted to change the colour of the bars in a bar graph via syntax. It can be done via clicking on the bars, but I don't want to have to do this each time I create a graph and my clumsiness has resulted in sometimes a single bar's colour being changed and then the background. I'm also interested in whether there is a SPSS manual for creating graphs? The following is v21 syntax. Thanks in advance, Bob GGRAPH /GRAPHDATASET NAME="graphdataset" VARIABLES=LSPtot COUNT()[name="COUNT"] MISSING=LISTWISE REPORTMISSING=NO /GRAPHSPEC SOURCE=INLINE. BEGIN GPL SOURCE: s=userSource(id("graphdataset")) DATA: LSPtot=col(source(s), name("LSPtot"), unit.category()) DATA: COUNT=col(source(s), name("COUNT")) GUIDE: axis(dim(1), label("Compliance subscale score")) GUIDE: axis(dim(2), label("Number of patients"), delta(50)) SCALE: linear(dim(2), include(0)) ELEMENT: interval(position(LSPtot*COUNT), shape.interior(shape.square)) 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 ===================== 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 |
ViAnn,
Thanks for your reply, which somewhat explained why web searches didn't provide much assistance because each version seems to have varying approaches (e.g. not sure where Igraph fits in). My work computer has various administrator controls so when I select help options the pages don't open, hence my interest in a manual. I think I'll stick to adding commands to some sytnax that I can recycle rather than develop templates. Adding color.lightblue to ELEMENT does the job. I wasn't sure whether I needed to add the color command to SCALE or GUIDE,as I had seem in some examples. Thanks again, Bob > This question comes up fairly often but has a complicated answer. I could > give you the simple answer here if I knew what color you want and under > what > circumstances you want it. There are many ways to generate a chart but > they > come down to two paths: > > 1. GPL via Chart Builder, GGRAPH, or charts built into procedures. Many > ways > to create it and one way to edit the resulting chart via the chart editor. > 2. Graphboard Template Chooser: One way to create it and one way to edit > via > the Graphboard Editor. > > GPL: When you create a bar graph via Chart Builder, it is generating GPL > (the stuff between BEGIN GPL and END GPL). Or you can type in your own > syntax using the GGRAPH command and GPL. GPL provides some basic functions > which can be used to control aesthetics like color, font, transparency, > symbols, etc. Of the these functions is the color function. So to change > your bars, you could use the color function and specify a color or RGB > values. For example, you could use color(color.blue) in the ELEMENT > statement. Now color.blue is a constant. If you look at Help > GPL > Reference >> GPL Statement and Function Reference > GPL Functions you will find the > color function and if you look at Help > GPL Reference > GPL Constants you > will find all the color constants. You could instead, specify a hex value > in > quotation marks if you have to know the rgb values. > > Templates: When you use the chart editor to change the color of a set of > bars (which you note that you have done), you can also save a template > within the chart editor and then make that the template you use in Chart > Builder or via the GGRAPH command using the TEMPLATE keyword. Once you > have > saved this template, you name it via Chart Builder>Options. > > Built-in Templates: If you always want the same color used for bars, > fills, > and lines in your charts, you can control that in a template to be applied > to almost any chart in Edit>Options. Click on the Charts Tab, and then > click > on the Colors sub tab. Your chart example here is an ungrouped chart, but > you can also set a color cycle for grouped or stacked chart via this user > interface. This becomes your default template to be applied to most all > charts. > > Graphboard Template Chooser: If you create a chart via this command, you > have a completely different set of options and I'll defer that discussion > for now. > > This is one complicated mess and a function of incrementally providing > more > formatting control in Graphics over a 20 year time period. There are lots > of > twisty passages in the formatting cave that kinda look alike but are > different (apologies to Adventure). > > -----Original Message----- > From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of > Bob > Green > Sent: Tuesday, September 17, 2013 5:54 PM > To: [hidden email] > Subject: Changing colour in a bar graph via syntax & manual info > > Hello, > > I wanted to change the colour of the bars in a bar graph via syntax. It > can > be done via clicking on the bars, but I don't want to have to do this each > time I create a graph and my clumsiness has resulted in sometimes a single > bar's colour being changed and then the background. > > I'm also interested in whether there is a SPSS manual for creating graphs? > The following is v21 syntax. > > Thanks in advance, > > Bob > > GGRAPH > /GRAPHDATASET NAME="graphdataset" VARIABLES=LSPtot COUNT()[name="COUNT"] > MISSING=LISTWISE REPORTMISSING=NO > /GRAPHSPEC SOURCE=INLINE. > BEGIN GPL > SOURCE: s=userSource(id("graphdataset")) > DATA: LSPtot=col(source(s), name("LSPtot"), unit.category()) > DATA: COUNT=col(source(s), name("COUNT")) > GUIDE: axis(dim(1), label("Compliance subscale score")) > GUIDE: axis(dim(2), label("Number of patients"), delta(50)) > SCALE: linear(dim(2), include(0)) > ELEMENT: interval(position(LSPtot*COUNT), shape.interior(shape.square)) > 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 > > ===================== > 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 > ===================== 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 |
The syntax you posted is GGRAPH syntax, and not IGRAPH syntax. If you are
also using IGRAPH, you have to use templates or the built-in template modified from Edit>Options The color function on the GUIDE statement controls the color for lines and axes. I do not recall a color function for the SCALE statement. I'm not sure why you can't get top help via Help>Topics. This should have been installed locally on your computer. You can see the help tree from: http://pic.dhe.ibm.com/infocenter/spssstat/v20r0m0/index.jsp and the pdf of the GPL reference here: ftp://public.dhe.ibm.com/software/analytics/spss/documentation/statistics/21 .0/en/client/Manuals/GPL_Reference_Guide_for_IBM_SPSS_Statistics.pdf (this is for release 21) -----Original Message----- From: [hidden email] [mailto:[hidden email]] Sent: Tuesday, September 17, 2013 7:06 PM To: ViAnn Beadle Cc: [hidden email] Subject: Re: Changing colour in a bar graph via syntax & manual info ViAnn, Thanks for your reply, which somewhat explained why web searches didn't provide much assistance because each version seems to have varying approaches (e.g. not sure where Igraph fits in). My work computer has various administrator controls so when I select help options the pages don't open, hence my interest in a manual. I think I'll stick to adding commands to some sytnax that I can recycle rather than develop templates. Adding color.lightblue to ELEMENT does the job. I wasn't sure whether I needed to add the color command to SCALE or GUIDE,as I had seem in some examples. Thanks again, Bob > This question comes up fairly often but has a complicated answer. I > could give you the simple answer here if I knew what color you want > and under what circumstances you want it. There are many ways to > generate a chart but they come down to two paths: > > 1. GPL via Chart Builder, GGRAPH, or charts built into procedures. > Many ways to create it and one way to edit the resulting chart via the > chart editor. > 2. Graphboard Template Chooser: One way to create it and one way to > edit via the Graphboard Editor. > > GPL: When you create a bar graph via Chart Builder, it is generating > GPL (the stuff between BEGIN GPL and END GPL). Or you can type in your > own syntax using the GGRAPH command and GPL. GPL provides some basic > functions which can be used to control aesthetics like color, font, > transparency, symbols, etc. Of the these functions is the color > function. So to change your bars, you could use the color function and > specify a color or RGB values. For example, you could use > color(color.blue) in the ELEMENT statement. Now color.blue is a > constant. If you look at Help > GPL Reference >> GPL Statement and Function Reference > GPL Functions you will find >> the > color function and if you look at Help > GPL Reference > GPL Constants > you will find all the color constants. You could instead, specify a > hex value in quotation marks if you have to know the rgb values. > > Templates: When you use the chart editor to change the color of a set > of bars (which you note that you have done), you can also save a > template within the chart editor and then make that the template you > use in Chart Builder or via the GGRAPH command using the TEMPLATE > keyword. Once you have saved this template, you name it via Chart > Builder>Options. > > Built-in Templates: If you always want the same color used for bars, > fills, and lines in your charts, you can control that in a template to > be applied to almost any chart in Edit>Options. Click on the Charts > Tab, and then click on the Colors sub tab. Your chart example here is > an ungrouped chart, but you can also set a color cycle for grouped or > stacked chart via this user interface. This becomes your default > template to be applied to most all charts. > > Graphboard Template Chooser: If you create a chart via this command, > you have a completely different set of options and I'll defer that > discussion for now. > > This is one complicated mess and a function of incrementally providing > more formatting control in Graphics over a 20 year time period. There > are lots of twisty passages in the formatting cave that kinda look > alike but are different (apologies to Adventure). > > -----Original Message----- > From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf > Of Bob Green > Sent: Tuesday, September 17, 2013 5:54 PM > To: [hidden email] > Subject: Changing colour in a bar graph via syntax & manual info > > Hello, > > I wanted to change the colour of the bars in a bar graph via syntax. > It can be done via clicking on the bars, but I don't want to have to > do this each time I create a graph and my clumsiness has resulted in > sometimes a single bar's colour being changed and then the background. > > I'm also interested in whether there is a SPSS manual for creating graphs? > The following is v21 syntax. > > Thanks in advance, > > Bob > > GGRAPH > /GRAPHDATASET NAME="graphdataset" VARIABLES=LSPtot > COUNT()[name="COUNT"] MISSING=LISTWISE REPORTMISSING=NO > /GRAPHSPEC SOURCE=INLINE. > BEGIN GPL > SOURCE: s=userSource(id("graphdataset")) > DATA: LSPtot=col(source(s), name("LSPtot"), unit.category()) > DATA: COUNT=col(source(s), name("COUNT")) > GUIDE: axis(dim(1), label("Compliance subscale score")) > GUIDE: axis(dim(2), label("Number of patients"), delta(50)) > SCALE: linear(dim(2), include(0)) > ELEMENT: interval(position(LSPtot*COUNT), > shape.interior(shape.square)) 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 > > ===================== > 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 > ===================== 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 |
In reply to this post by bgreen
Changing inline GPL to set a specific color is not that hard. Something like "color.interior(color.grey)" in the ELEMENT statement generating the bars for example.
ELEMENT: interval(position(LSPtot*COUNT), shape.interior(shape.square), color.interior(color.grey)) Changing the default color for bars in the template is more annoying, I just found whatever the default tan color was in the template file and did a find and replace for all of that Hexidecimal color code in the document. |
If you want to change the default colors,
there is no need to do what Andy suggests below. Just go to Edit
> Options >Charts, click the Colors button, and choose the color
you want. Style cycle colors can be similarly modified.
Jon Peck (no "h") aka Kim Senior Software Engineer, IBM [hidden email] phone: 720-342-5621 From: Andy W <[hidden email]> To: [hidden email], Date: 09/18/2013 06:02 AM Subject: Re: [SPSSX-L] Changing colour in a bar graph via syntax & manual info Sent by: "SPSSX(r) Discussion" <[hidden email]> Changing inline GPL to set a specific color is not that hard. Something like "color.interior(color.grey)" in the ELEMENT statement generating the bars for example. ELEMENT: interval(position(LSPtot*COUNT), shape.interior(shape.square), color.interior(color.grey)) Changing the default color for bars in the template is more annoying, I just found whatever the default tan color was in the template file and did a find and replace for all of that Hexidecimal color code in the document. ----- Andy W [hidden email] http://andrewpwheeler.wordpress.com/ -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Changing-colour-in-a-bar-graph-via-syntax-manual-info-tp5722078p5722086.html Sent from the SPSSX Discussion mailing list archive at Nabble.com. ===================== 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 |
Thanks Jon and Andy,
I'll try both options but I like Andy's option as I can build it into the syntax that I am developing. Regards Bob At 10:21 PM 18/09/2013, Jon K Peck wrote: >If you want to change the default colors, there is no need to do >what Andy suggests below. Just go to Edit > Options >Charts, click >the Colors button, and choose the color you want. Style cycle >colors can be similarly modified. > > >Jon Peck (no "h") aka Kim >Senior Software Engineer, IBM >[hidden email] >phone: 720-342-5621 > > > > >From: Andy W <[hidden email]> >To: [hidden email], >Date: 09/18/2013 06:02 AM >Subject: Re: [SPSSX-L] Changing colour in a bar graph via >syntax & manual info >Sent by: "SPSSX(r) Discussion" <[hidden email]> > > > > >Changing inline GPL to set a specific color is not that hard. Something like >"color.interior(color.grey)" in the ELEMENT statement generating the bars >for example. > >ELEMENT: interval(position(LSPtot*COUNT), shape.interior(shape.square), >color.interior(color.grey)) > >Changing the default color for bars in the template is more annoying, I just >found whatever the default tan color was in the template file and did a find >and replace for all of that Hexidecimal color code in the document. > > > >----- >Andy W >[hidden email] ><http://andrewpwheeler.wordpress.com/>http://andrewpwheeler.wordpress.com/ >-- >View this message in context: ><http://spssx-discussion.1045642.n5.nabble.com/Changing-colour-in-a-bar-graph-via-syntax-manual-info-tp5722078p5722086.html>http://spssx-discussion.1045642.n5.nabble.com/Changing-colour-in-a-bar-graph-via-syntax-manual-info-tp5722078p5722086.html >Sent from the SPSSX Discussion mailing list archive at Nabble.com. > >===================== >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 > ===================== 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 |
Free forum by Nabble | Edit this page |