Hi All,
Is there a way to change the colour of the background on a line or a scatter graph based on values on the y axes?
Say I am making a line chart, with date as the x variable and fat level as the y variable, and I wish to have the colour of the background in the graph to be green when the value of y is between 4 and 4.8, and orange when the value of y is between 3.3 and 4,
and red when the value of y is < 3.3. Is there a way to do this?
Same in a scatter plot/chart?
Appreciate the help.
Regards
H.Z.
|
I don't think this is possible. An alternative would be to add reference lines at the upper and lower boundaries. On Sun, Oct 4, 2020 at 1:31 PM Hassan Taweel <[hidden email]> wrote:
|
Administrator
|
Can one generate a heat map plot to get the desired shaded areas and then
overlay a scatter-plot? That approach worked in Stata (where contour = heat map): clear * sysuse auto * Overlay a scatter-plot on a heat map plot twoway contour mpg mpg weight, ccuts(20 30) || /// scatter mpg weight, msymbol(Oh) mcolor(black) Stata_heatmap_scatterplot_overlay.png <http://spssx-discussion.1045642.n5.nabble.com/file/t7186/Stata_heatmap_scatterplot_overlay.png> Andy W has a page on making heat maps with SPSS, which may be helpful: https://andrewpwheeler.com/2017/01/11/heatmaps-in-spss/ I don't know if one can easily overlay a scatter-plot. HTH. Jon Peck wrote > I don't think this is possible. An alternative would be to add reference > lines at the upper and lower boundaries. > > On Sun, Oct 4, 2020 at 1:31 PM Hassan Taweel < > hassantaweel@ > > > wrote: > >> Hi All, >> >> Is there a way to change the colour of the background on a line or a >> scatter graph based on values on the y axes? >> Say I am making a line chart, with date as the x variable and fat level >> as >> the y variable, and I wish to have the colour of the background in the >> graph to be green when the value of y is between 4 and 4.8, and orange >> when >> the value of y is between 3.3 and 4, and red when the value of y is < >> 3.3. >> Is there a way to do this? >> Same in a scatter plot/chart? >> >> Appreciate the help. >> Regards >> H.Z. >> >> ===================== To manage your subscription to SPSSX-L, send a >> message to > LISTSERV@.UGA > (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 > > > > -- > Jon K Peck > jkpeck@ > > ===================== > To manage your subscription to SPSSX-L, send a message to > LISTSERV@.UGA > (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 ----- -- Bruce Weaver [hidden email] http://sites.google.com/a/lakeheadu.ca/bweaver/ "When all else fails, RTFM." NOTE: My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above. -- Sent from: http://spssx-discussion.1045642.n5.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
--
Bruce Weaver bweaver@lakeheadu.ca http://sites.google.com/a/lakeheadu.ca/bweaver/ "When all else fails, RTFM." PLEASE NOTE THE FOLLOWING: 1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above. 2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/). |
One approach I have listed here,
https://andrewpwheeler.com/2013/04/03/some-notes-on-single-line-charts-in-spss/. So that is piping it in manually. For a data based approach here is how I would try to tackle it. If you have a bunch, you need a dataset that defines the corner of the boxes (begin/end here is the X variable, bottom/top is Y), then in this part map to a color and an id for each unique box: ELEMENT: polygon(position(link.hull((begin + end)*(bottom + top))), color.interior(??COLORVARIABLE??), transparency.interior(transparency."0.5"), split(??IDFOREACHBOX??)) Sorry cannot test it out to show, no more SPSS for me since not at a Uni anymore. ----- Andy W [hidden email] http://andrewpwheeler.wordpress.com/ -- Sent from: http://spssx-discussion.1045642.n5.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 |
Administrator
|
Andy, given the nature of your website, I reckon you ought to be eligible for
an author's license. John Hall, are you still getting your SPSS that way? If so, please direct Andy to where he can get one too! Cheers, Bruce Andy W wrote > --- snip --- > Sorry cannot test it out to show, no more SPSS for me since not at a Uni > anymore. > --- snip --- ----- -- Bruce Weaver [hidden email] http://sites.google.com/a/lakeheadu.ca/bweaver/ "When all else fails, RTFM." NOTE: My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above. -- Sent from: http://spssx-discussion.1045642.n5.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
--
Bruce Weaver bweaver@lakeheadu.ca http://sites.google.com/a/lakeheadu.ca/bweaver/ "When all else fails, RTFM." PLEASE NOTE THE FOLLOWING: 1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above. 2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/). |
I fully uphold the notion: Andy's gimmicks and the site are great!
05.10.2020 17:26, Bruce Weaver пишет: > Andy, given the nature of your website, I reckon you ought to be eligible for > an author's license. > > John Hall, are you still getting your SPSS that way? If so, please direct > Andy to where he can get one too! > > Cheers, > Bruce > ===================== 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 Bruce Weaver
It certainly would be in IBM/SPSS's interest/benefit to be sure that retired
long time contributors to this forum/list continue to help the SPSS community. Contributors to this list such as Andy, John, Jon, David, Bruce, ViAnn, Kiril, Progman, Eugene, Marta, Ryan, Anthony, and others have been extremely helpful to me and I am sure to many others. It goes without saying that retirees have more experience than beginners. Disclosure. I already have a lifetime license for 8 seats with all the modules so such a practice would not benefit me. ----- Art Kendall Social Research Consultants -- Sent from: http://spssx-discussion.1045642.n5.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
Art Kendall
Social Research Consultants |
In reply to this post by Bruce Weaver
Well, life is weird. Doing some work with folks at Georgia State Univ, and my
affiliated ID stuff went through just today. They let students/faculty have a license for their personal machine at that uni, so just piped in the code for my V26 and I am good for now anyway. So here is a bit lengthy example of setting up the data to do what I think the OP wants and mashing up the boxes with a time series line plot. **********************************************************. data list free / year VCR. begin data 1985 1881.3 1986 1995.2 1987 2036.1 1988 2217.6 1989 2299.9 1990 2383.6 1991 2318.2 1992 2163.7 1993 2089.8 1994 1860.9 1995 1557.8 1996 1344.2 1997 1268.4 1998 1167.4 1999 1062.6 2000 945.2 2001 927.5 2002 789.6 2003 734.1 2004 687.4 2005 673.1 2006 637.9 2007 613.8 2008 580.3 2009 551.8 2010 593.1 end data. DATASET NAME Crime. formats year VCR (F4.0). *Computing regimes based on Y axis value. DO IF VCR < 1000. COMPUTE Regime = 1. ELSE IF VCR < 2000. COMPUTE Regime = 2. ELSE. COMPUTE Regime = 3. END IF. FORMATS Regime (F1.0). EXECUTE. DO IF $casenum = 1. COMPUTE RegimeID = 1. ELSE IF Regime = LAG(Regime). COMPUTE RegimeID = LAG(RegimeID). ELSE IF Regime <> LAG(Regime). COMPUTE RegimeID = LAG(RegimeID) + 1. END IF. FORMATS RegimeID (F3.0). EXECUTE. DATASET DECLARE Boxes. AGGREGATE OUTFILE='Boxes' /BREAK RegimeID /Regime = FIRST(Regime) /begin = MIN(year) /end = MAX(year). DATASET ACTIVATE Boxes. COMPUTE begin = begin - 0.5. COMPUTE end = end + 0.5. COMPUTE bottom = -1. COMPUTE top = 3000. FORMATS bottom top (F4.0). *Due to formats does not show, but this works. EXECUTE. GGRAPH /GRAPHDATASET NAME="b" DATASET=boxes VARIABLES=begin end bottom top Regime RegimeID /GRAPHDATASET NAME="v" DATASET=Crime VARIABLES=year VCR /GRAPHSPEC SOURCE=INLINE /FRAME INNER=YES. BEGIN GPL SOURCE: b=userSource(id("b")) DATA: begin=col(source(b), name("begin")) DATA: end=col(source(b), name("end")) DATA: bottom=col(source(b), name("bottom")) DATA: top=col(source(b), name("top")) DATA: Regime=col(source(b), name("Regime"), unit.category()) DATA: RegimeID=col(source(b), name("RegimeID"), unit.category()) SOURCE: v=userSource(id("v")) DATA: year=col(source(v), name("year")) DATA: VCR=col(source(v), name("VCR")) SCALE: linear(dim(1), min(1985), max(2010)) SCALE: linear(dim(2), min(500), max(2500)) GUIDE: legend(aesthetic(aesthetic.color.interior), null()) GUIDE: axis(dim(1), label("Year")) GUIDE: axis(dim(2), label("Violent Crime Rate per 100,000")) ELEMENT: polygon(position(link.hull((begin + end)*(bottom + top))), color.interior(Regime), split(RegimeID), transparency.interior(transparency."0.5"), transparency.exterior(transparency."1")) ELEMENT: line(position(year*VCR), color.interior(color.black), size(size."1")) ELEMENT: point(position(year*VCR), color.interior(color.black), color.exterior(color.white), size(size."8px")) END GPL. **********************************************************. <http://spssx-discussion.1045642.n5.nabble.com/file/t329824/Background.png> ----- Andy W [hidden email] http://andrewpwheeler.wordpress.com/ -- Sent from: http://spssx-discussion.1045642.n5.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 |
In reply to this post by Art Kendall
It was simply a brain lapse that I omitted Rich.
He has often provided valuable insight. ----- Art Kendall Social Research Consultants -- Sent from: http://spssx-discussion.1045642.n5.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
Art Kendall
Social Research Consultants |
In reply to this post by Andy W
I resurected this thread to keep things congruent and so other folks can. Andy, I adjusted your syntax for my current work on looking at the alteration in mental health services due to COVID. My example below has two differences - the regime ID is the same as the regime, and the change in background is based on the X-axis rather than the Y-axis. I get a nice palette with the right colors but no line. Any ideas? data list free / MOM avgservices. begin data 1 3.21 2 2.78 3 2.65 4 2.90 5 2.89 6 3.12 7 3.63 8 3.19 9 3.21 10 3.19 11 2.92 12 2.90 end data. DATASET NAME momservices. formats MOM (F4.0) avgservices (F4.2). *Computing regimes based on Y axis value. DO IF mom < 7. COMPUTE Regime = 1. ELSE IF mom < 9. COMPUTE Regime = 2. ELSE. COMPUTE Regime = 3. END IF. FORMATS Regime (F1.0). EXECUTE. *Computing regime ID based on regime.* compute regimeid=regime . execute . DATASET DECLARE Boxes1. AGGREGATE OUTFILE='Boxes1' /BREAK RegimeID /Regime = FIRST(Regime) /begin = MIN(mom) /end = MAX(mom). DATASET ACTIVATE Boxes1. COMPUTE begin = begin - 0.5. COMPUTE end = end + 0.5. COMPUTE bottom = -1. COMPUTE top = 5. FORMATS bottom top (F4.0). *Due to formats does not show, but this works. EXECUTE. GGRAPH /GRAPHDATASET NAME="b" DATASET=boxes1 VARIABLES=begin end bottom top Regime RegimeID /GRAPHDATASET NAME="s" DATASET=momservices VARIABLES=mom avgservices /GRAPHSPEC SOURCE=INLINE /FRAME INNER=YES. BEGIN GPL SOURCE: b=userSource(id("b")) DATA: begin=col(source(b), name("begin")) DATA: end=col(source(b), name("end")) DATA: bottom=col(source(b), name("bottom")) DATA: top=col(source(b), name("top")) DATA: Regime=col(source(b), name("Regime"), unit.category()) DATA: RegimeID=col(source(b), name("RegimeID"), unit.category()) SOURCE: s=userSource(id("s")) DATA: MOM=col(source(s), name("MOM")) DATA: avgservices=col(source(s), name("avgservices")) SCALE: linear(dim(1), min(1), max(12)) SCALE: linear(dim(2), min(0), max(4.00)) GUIDE: legend(aesthetic(aesthetic.color.interior), null()) GUIDE: axis(dim(1), label("Month")) GUIDE: axis(dim(2), label("Mean Services per Month per Consumer")) ELEMENT: polygon(position(link.hull((begin + end)*(bottom + top))), color.interior(Regime), split(RegimeID), transparency.interior(transparency."0.5"), transparency.exterior(transparency."1")) ELEMENT: line(position(MOM*avgservices), color.interior(color.black), size(size."1")) ELEMENT: point(position(MOM*avgservices), color.interior(color.black), color.exterior(color.white), size(size."8px")) END GPL. Brian G. Dates, M.A. Consultant in Program Evaluation, Research, and Statistics 248-229-2865 email:[hidden email] email: [hidden email] On Mon, Oct 5, 2020 at 3:37 PM Andy W <[hidden email]> wrote: Well, life is weird. Doing some work with folks at Georgia State Univ, and my |
GGRAPH case matters for variable names and transforms (although IMO this should have given you an error). I am able to replicate the no line, and if I change below I get the line as needed. DATA: MOM=col(source(s), name("mom")) Bit confusing, since MOM is uppercase in the original dataset, but you have it as /GRAPHDATASET VARIABLES=mom. I guess the later wins, not the actual case in the dataset. On Mon, Nov 23, 2020 at 8:35 AM Brian Dates <[hidden email]> wrote:
|
Andy, Thanks. This is great. I thought I had all the cases correct. Take care. Brian Brian G. Dates, M.A. Consultant in Program Evaluation, Research, and Statistics 248-229-2865 email:[hidden email] email: [hidden email] On Mon, Nov 23, 2020 at 9:50 AM Andrew Wheeler <[hidden email]> wrote:
|
Free forum by Nabble | Edit this page |