|
Hi all,
I wish to draw a scatterplot with markers defined by two categorical variables - one for the colour and the second for the shape. I have data such as the following: data list free / group item x y. begin data. 1 1 856 385 1 2 1142 824 1 3 1064 497 1 4 1036 543 1 5 547 796 1 6 576 507 1 7 1050 488 2 1 1688 673 2 2 1093 367 2 3 1050 545 2 4 1043 740 2 5 775 293 2 6 1621 495 2 7 869 403 3 1 1008 488 3 2 570 338 3 3 656 756 3 4 1485 794 3 5 1394 322 3 6 1345 540 3 7 1159 619 end data. I'm trying to generate a scatterplot of x vs y, with colours set according to the 'group' variable, and the marker shape set according to the 'items' variable. I don't know if it needs the 'group' and 'item' variables as I've got them, or a new variable for the combination (ie, values 1-21)? I don't really know enough about GPL to know where to start with this one. Any suggestions would be appreciated. Thanks, Kylie. ===================== 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 |
|
Note that x and y need a scale measurement level, here set in GGRAPH but alternatively in the Data Editor. You can generate most of this from the Chart Builder. The extra part is for item, which is used in the ELEMENT command to set the shape. HTH, Jon Peck GGRAPH /GRAPHDATASET NAME="graphdataset" VARIABLES=x[LEVEL=SCALE] y[LEVEL=SCALE] group item MISSING=LISTWISE REPORTMISSING=NO /GRAPHSPEC SOURCE=INLINE. BEGIN GPL SOURCE: s=userSource(id("graphdataset")) DATA: x=col(source(s), name("x")) DATA: y=col(source(s), name("y")) DATA: group=col(source(s), name("group"), unit.category()) DATA: item=col(source(s), name("item"), unit.category()) GUIDE: axis(dim(1), label("x")) GUIDE: axis(dim(2), label("y")) GUIDE: legend(aesthetic(aesthetic.color.exterior), label("group")) ELEMENT: point(position(x*y), color.exterior(group), shape(item)) END GPL Jon Peck SPSS, an IBM Company [hidden email] 312-651-3435
Hi all, I wish to draw a scatterplot with markers defined by two categorical variables - one for the colour and the second for the shape. I have data such as the following: data list free / group item x y. begin data. 1 1 856 385 1 2 1142 824 1 3 1064 497 1 4 1036 543 1 5 547 796 1 6 576 507 1 7 1050 488 2 1 1688 673 2 2 1093 367 2 3 1050 545 2 4 1043 740 2 5 775 293 2 6 1621 495 2 7 869 403 3 1 1008 488 3 2 570 338 3 3 656 756 3 4 1485 794 3 5 1394 322 3 6 1345 540 3 7 1159 619 end data. I'm trying to generate a scatterplot of x vs y, with colours set according to the 'group' variable, and the marker shape set according to the 'items' variable. I don't know if it needs the 'group' and 'item' variables as I've got them, or a new variable for the combination (ie, values 1-21)? I don't really know enough about GPL to know where to start with this one. Any suggestions would be appreciated. Thanks, Kylie. ===================== 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 Kylie
Use chart builder to generate the syntax for just the group and then add to
the syntax the necessary stuff for item. Here's the syntax: variable level x y (scale). * Chart Builder. GGRAPH /GRAPHDATASET NAME="graphdataset" VARIABLES=x y group item MISSING=LISTWISE REPORTMISSING=NO /GRAPHSPEC SOURCE=INLINE. BEGIN GPL SOURCE: s=userSource(id("graphdataset")) DATA: x=col(source(s), name("x")) DATA: y=col(source(s), name("y")) DATA: group=col(source(s), name("group"), unit.category()) DATA: item=col(source(s), name("item"), unit.category()) GUIDE: axis(dim(1), label("x")) GUIDE: axis(dim(2), label("y")) GUIDE: legend(aesthetic(aesthetic.color.exterior), label("group")) GUIDE: legend(aesthetic(aesthetic.shape), label("item")) ELEMENT: point(position(x*y), color.exterior(group), shape(item)) END GPL. Additions: Add item to the VARIABLES keyword on the GRAPHDATASET subcommand. Add a DATA statement to define the item as a categorical variable. Add a GUIDE statement to define the label for item legend. Add the shape(item) function to the ELEMENT statement. Note-- I personally prefer the color function which sets color for both the border and the fill as opposed to the color.exterior function which sets color only for the border and leaves the marker unfilled. The designer of the UI was being cautious and felt that solid fills would obscure overlying points. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Kylie Lange Sent: Wednesday, February 17, 2010 11:02 PM To: [hidden email] Subject: scatterplot with double legend Hi all, I wish to draw a scatterplot with markers defined by two categorical variables - one for the colour and the second for the shape. I have data such as the following: data list free / group item x y. begin data. 1 1 856 385 1 2 1142 824 1 3 1064 497 1 4 1036 543 1 5 547 796 1 6 576 507 1 7 1050 488 2 1 1688 673 2 2 1093 367 2 3 1050 545 2 4 1043 740 2 5 775 293 2 6 1621 495 2 7 869 403 3 1 1008 488 3 2 570 338 3 3 656 756 3 4 1485 794 3 5 1394 322 3 6 1345 540 3 7 1159 619 end data. I'm trying to generate a scatterplot of x vs y, with colours set according to the 'group' variable, and the marker shape set according to the 'items' variable. I don't know if it needs the 'group' and 'item' variables as I've got them, or a new variable for the combination (ie, values 1-21)? I don't really know enough about GPL to know where to start with this one. Any suggestions would be appreciated. Thanks, Kylie. ===================== 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 Jon K Peck
p.s. You can generate this chart entirely from the user interface by using GraphBoard (on the Graphics menu). On the detailed tab you can set both the shape and color variables (as well as size and transparency variables). Jon Peck SPSS, an IBM Company [hidden email] 312-651-3435
Note that x and y need a scale measurement level, here set in GGRAPH but alternatively in the Data Editor. You can generate most of this from the Chart Builder. The extra part is for item, which is used in the ELEMENT command to set the shape. HTH, Jon Peck GGRAPH /GRAPHDATASET NAME="graphdataset" VARIABLES=x[LEVEL=SCALE] y[LEVEL=SCALE] group item MISSING=LISTWISE REPORTMISSING=NO /GRAPHSPEC SOURCE=INLINE. BEGIN GPL SOURCE: s=userSource(id("graphdataset")) DATA: x=col(source(s), name("x")) DATA: y=col(source(s), name("y")) DATA: group=col(source(s), name("group"), unit.category()) DATA: item=col(source(s), name("item"), unit.category()) GUIDE: axis(dim(1), label("x")) GUIDE: axis(dim(2), label("y")) GUIDE: legend(aesthetic(aesthetic.color.exterior), label("group")) ELEMENT: point(position(x*y), color.exterior(group), shape(item)) END GPL Jon Peck SPSS, an IBM Company [hidden email] 312-651-3435
Hi all, I wish to draw a scatterplot with markers defined by two categorical variables - one for the colour and the second for the shape. I have data such as the following: data list free / group item x y. begin data. 1 1 856 385 1 2 1142 824 1 3 1064 497 1 4 1036 543 1 5 547 796 1 6 576 507 1 7 1050 488 2 1 1688 673 2 2 1093 367 2 3 1050 545 2 4 1043 740 2 5 775 293 2 6 1621 495 2 7 869 403 3 1 1008 488 3 2 570 338 3 3 656 756 3 4 1485 794 3 5 1394 322 3 6 1345 540 3 7 1159 619 end data. I'm trying to generate a scatterplot of x vs y, with colours set according to the 'group' variable, and the marker shape set according to the 'items' variable. I don't know if it needs the 'group' and 'item' variables as I've got them, or a new variable for the combination (ie, values 1-21)? I don't really know enough about GPL to know where to start with this one. Any suggestions would be appreciated. Thanks, Kylie. ===================== 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 ViAnn Beadle
1. Yes. Try Graphboard instead if that’s what you want. 2. Templates are really fragile—every time I find a bug I report it. The basic problem is that they predate all of the flexibility of the newer procedures to produce charts. From: kornbrot [mailto:[hidden email]]
Use chart builder to generate the syntax for just the group and then add to Professor Diana Kornbrot |
| Free forum by Nabble | Edit this page |
