I have what might or might not be a complex graph to do. On one graph, I'd like to show the ranges for six variables, a bar or line to indicate the mean of the variable and a dot or point to indicate how a specific group scored on each of the variables. So you look at the chart and see for group A its mean and score range for variable X and a dot showing the group B mean on that variable. Nicely compact!
I've reading over the GPL manual and see how to do a range and I figure that a line isn't too hard and a dot might not be either provided the data are structured right, which is kind of a question. But that's not THE question. The question is putting multiple variables on the same plot. There is a faceted example and a clustered example but neither is quite what I have in mind, I don't think. How is that done? Thanks, Gene Maguin ===================== 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 |
I assume that your six variables have the same scale.
If you are comparing variables, it's going to be a lot easier if you use VARSTOCASES first to create one variable with six times as many cases as variables. As long as you have the same X and Y axes, you can overlay multiple elements in it. I usually start with Chart Builder and design a chart that has no summary statistic by specifying the "Value" statistic. This just passes a nice un-aggregated matrix of data to the generator and I use functions (in this instance, summary.mean) within GPL to summarize data such as group means. Here's an example: *Gen up some data first. input program. loop #i = 1 to 20. do repeat vars=var1 to var6. compute vars = RV.NORMAL(0,1). end repeat. compute groups=RND(RV.UNIFORM(0,1)). end case. end loop. end file. end input program. * Restructure. VARSTOCASES /MAKE Values FROM var1 var2 var3 var4 var5 var6 /INDEX=Variables(6) /KEEP=groups /NULL=KEEP. VALUE LABELS Variables 1 "Var1" 2 "Var2" 3 "Var3" 4 "Var4" 5 "Var5" 6 "Var6". GGRAPH /GRAPHDATASET NAME="graphdataset" VARIABLES=Variables Values groups MISSING=LISTWISE REPORTMISSING=NO /GRAPHSPEC SOURCE=INLINE. BEGIN GPL SOURCE: s=userSource(id("graphdataset")) DATA: Variables=col(source(s), name("Variables"), unit.category()) DATA: Values=col(source(s), name("Values")) DATA: groups=col(source(s), name("groups"), unit.category()) GUIDE: axis(dim(1), label("Variables")) GUIDE: axis(dim(2), label("Values")) GUIDE: legend(aesthetic(aesthetic.color.exterior), label("groups")) SCALE: cat(dim(1), include("1", "2", "3", "4", "5", "6")) SCALE: linear(dim(2), include(0)) ELEMENT: interval(position(region.spread.range(Variables*Values))), shape(shape.square)) ELEMENT: point(position(summary.mean(Variables*Values)), color(groups)) ELEMENT: point(position(summary.mean(Variables*Values)), color("Pop Mean")) END GPL. Notes: Elements are drawn in the order they used so that the interval element is drawn first, then the points for the subgroup means, and finally a point for Population Mean. When the aesthetic (in this instance, color) is assigned to a categorical variable, a point distinguished by color is generated for each value of the categorical variable. When the aesthetic is given a constant, there are no subgroups and a single point is displayed. The text of the constant is displayed in the legend. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Maguin, Eugene Sent: Thursday, June 07, 2012 3:53 PM To: [hidden email] Subject: gpl question I have what might or might not be a complex graph to do. On one graph, I'd like to show the ranges for six variables, a bar or line to indicate the mean of the variable and a dot or point to indicate how a specific group scored on each of the variables. So you look at the chart and see for group A its mean and score range for variable X and a dot showing the group B mean on that variable. Nicely compact! I've reading over the GPL manual and see how to do a range and I figure that a line isn't too hard and a dot might not be either provided the data are structured right, which is kind of a question. But that's not THE question. The question is putting multiple variables on the same plot. There is a faceted example and a clustered example but neither is quite what I have in mind, I don't think. How is that done? Thanks, Gene Maguin ===================== 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 |
Can I squeeze in some general GPL questions? Are GPL, ViZml and ggplot2 three implementations of the Grammar of Graphics? Or is GPL code stored internally in an xml representation called ViZml? I find the defaults of ggplot2 visually very pleasing. Is it possible to change those defaults in GPL once and for all and make them similar to those of ggplot2?
Regards,
Albert-Jan ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ All right, but apart from the sanitation, the medicine, education, wine, public order, irrigation, roads, a fresh water system, and public health, what have the Romans ever done for us? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
In reply to this post by ViAnn Beadle
ViAnn, thanks for your help. A key piece is that group variable and it would have taken a long time to figure that out.
Gene Maguin -----Original Message----- From: ViAnn Beadle [mailto:[hidden email]] Sent: Thursday, June 07, 2012 9:02 PM To: Maguin, Eugene; [hidden email] Subject: RE: gpl question I assume that your six variables have the same scale. If you are comparing variables, it's going to be a lot easier if you use VARSTOCASES first to create one variable with six times as many cases as variables. As long as you have the same X and Y axes, you can overlay multiple elements in it. I usually start with Chart Builder and design a chart that has no summary statistic by specifying the "Value" statistic. This just passes a nice un-aggregated matrix of data to the generator and I use functions (in this instance, summary.mean) within GPL to summarize data such as group means. Here's an example: *Gen up some data first. input program. loop #i = 1 to 20. do repeat vars=var1 to var6. compute vars = RV.NORMAL(0,1). end repeat. compute groups=RND(RV.UNIFORM(0,1)). end case. end loop. end file. end input program. * Restructure. VARSTOCASES /MAKE Values FROM var1 var2 var3 var4 var5 var6 /INDEX=Variables(6) /KEEP=groups /NULL=KEEP. VALUE LABELS Variables 1 "Var1" 2 "Var2" 3 "Var3" 4 "Var4" 5 "Var5" 6 "Var6". GGRAPH /GRAPHDATASET NAME="graphdataset" VARIABLES=Variables Values groups MISSING=LISTWISE REPORTMISSING=NO /GRAPHSPEC SOURCE=INLINE. BEGIN GPL SOURCE: s=userSource(id("graphdataset")) DATA: Variables=col(source(s), name("Variables"), unit.category()) DATA: Values=col(source(s), name("Values")) DATA: groups=col(source(s), name("groups"), unit.category()) GUIDE: axis(dim(1), label("Variables")) GUIDE: axis(dim(2), label("Values")) GUIDE: legend(aesthetic(aesthetic.color.exterior), label("groups")) SCALE: cat(dim(1), include("1", "2", "3", "4", "5", "6")) SCALE: linear(dim(2), include(0)) ELEMENT: interval(position(region.spread.range(Variables*Values))), shape(shape.square)) ELEMENT: point(position(summary.mean(Variables*Values)), color(groups)) ELEMENT: point(position(summary.mean(Variables*Values)), color("Pop Mean")) END GPL. Notes: Elements are drawn in the order they used so that the interval element is drawn first, then the points for the subgroup means, and finally a point for Population Mean. When the aesthetic (in this instance, color) is assigned to a categorical variable, a point distinguished by color is generated for each value of the categorical variable. When the aesthetic is given a constant, there are no subgroups and a single point is displayed. The text of the constant is displayed in the legend. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Maguin, Eugene Sent: Thursday, June 07, 2012 3:53 PM To: [hidden email] Subject: gpl question I have what might or might not be a complex graph to do. On one graph, I'd like to show the ranges for six variables, a bar or line to indicate the mean of the variable and a dot or point to indicate how a specific group scored on each of the variables. So you look at the chart and see for group A its mean and score range for variable X and a dot showing the group B mean on that variable. Nicely compact! I've reading over the GPL manual and see how to do a range and I figure that a line isn't too hard and a dot might not be either provided the data are structured right, which is kind of a question. But that's not THE question. The question is putting multiple variables on the same plot. There is a faceted example and a clustered example but neither is quite what I have in mind, I don't think. How is that done? Thanks, Gene Maguin ===================== 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 |