scatterplot with double legend

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

scatterplot with double legend

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

Re: scatterplot with double legend

Jon K Peck

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



From: Kylie Lange <[hidden email]>
To: [hidden email]
Date: 02/17/2010 11:05 PM
Subject: [SPSSX-L] scatterplot with double legend
Sent by: "SPSSX(r) Discussion" <[hidden email]>





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


Reply | Threaded
Open this post in threaded view
|

Re: scatterplot with double legend

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

Re: scatterplot with double legend

Jon K Peck
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



From: Jon K Peck/Chicago/IBM@IBMUS
To: [hidden email]
Date: 02/18/2010 07:56 AM
Subject: Re: [SPSSX-L] scatterplot with double legend
Sent by: "SPSSX(r) Discussion" <[hidden email]>






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


From: Kylie Lange <[hidden email]>
To: [hidden email]
Date: 02/17/2010 11:05 PM
Subject: [SPSSX-L] scatterplot with double legend
Sent by: "SPSSX(r) Discussion" <[hidden email]>






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




Reply | Threaded
Open this post in threaded view
|

Re: scatterplot with double legend

ViAnn Beadle
In reply to this post by ViAnn Beadle
Re: scatterplot with double legend

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]]
Sent: Thursday, February 18, 2010 8:20 AM
To: ViAnn Beadle; SPSSX(r) Discussion
Cc: Kyle Weeks
Subject: Re: scatterplot with double legend

 

  1. Does this mean that it is IMPOSSIBLE to generate 2 categories from chart builder alone? Of course this was possible in the discontinued igraph
  2. IF one saves to a .sgt template file, will ALL the specifications get saved?  My experience is that some things, e.g. the setting to  NOT show the regression equation for linear fit lines, do not get saved.  Of course inserting fit lines is only available by editing a generated graph, not in the chart builder dialogue boxes [as was so convenient in igraph]


Best
Diana


On 18/02/2010 14:56, "ViAnn Beadle" <vab88011@...> wrote:

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 [[hidden email]] On Behalf Of
Kylie Lange
Sent: Wednesday, February 17, 2010 11:02 PM
To: SPSSX-L@...
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
LISTSERV@... (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
LISTSERV@... (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

 


Professor Diana Kornbrot
email:  d.e.kornbrot@...    
web:    http://web.me.com/kornbrot/KornbrotHome.html
Work
School of Psychology
 University of Hertfordshire
 College Lane, Hatfield, Hertfordshire AL10 9AB, UK
 voice:   +44 (0) 170 728 4626
   fax:     +44 (0) 170 728 5073
Home
 
19 Elmhurst Avenue
 London N2 0LT, UK
    voice:   +44 (0) 208 883  3657
    mobile: +44 (0) 796 890 2102
   fax:      +44 (0) 870 706 4997