How to get density scatterplot

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

How to get density scatterplot

msherman

Dear Listers;  I am attempting to get a scatter plot that reveals the density at each data point, however, after numerous tries I have been unsuccessful.  Any advice will be appreciated. Thanks,

 

Martin F. Sherman, Ph.D.

Professor of Psychology

Director of  Masters Education in Psychology: Thesis Track

 

Loyola University Maryland

Department of Psychology

222 B Beatty Hall

4501 North Charles Street

Baltimore, MD 21210

 

410-617-2417

[hidden email]

 

Reply | Threaded
Open this post in threaded view
|

Re: How to get density scatterplot

Jon K Peck
What type of plot do you want?  One possibility would be a binned scatterplot, which you can select from the Graphs>Graphboard Template Chooser.

HTH,
Jon Peck

Jon Peck
Senior Software Engineer, IBM
[hidden email]
312-651-3435




From:        Martin Sherman <[hidden email]>
To:        [hidden email]
Date:        04/03/2011 01:11 PM
Subject:        [SPSSX-L] How to get density scatterplot
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




Dear Listers;  I am attempting to get a scatter plot that reveals the density at each data point, however, after numerous tries I have been unsuccessful.  Any advice will be appreciated. Thanks,
 
Martin F. Sherman, Ph.D.
Professor of Psychology
Director of  Masters Education in Psychology: Thesis Track
 
Loyola University Maryland
Department of Psychology
222 B Beatty Hall
4501 North Charles Street
Baltimore, MD 21210
 
410-617-2417
msherman@...
 
Reply | Threaded
Open this post in threaded view
|

Re: How to get density scatterplot

Albert-Jan Roskam
In reply to this post by msherman
Hi Martin,

Like Jon suggested, you could use 2D bins. You can do that in R with ggplot2: http://had.co.nz/ggplot2/stat_bin2d.html
Useful for when you have lots of data points (and it has shiny colours --> nice to impress management ;-).

Alternatively, you can use alpha scales to indicate intensity, or add random noise (jitter). The latter can also easily be done in plain syntax, by adding rv.uniform(0,1) or something similar to your data so the data points don't perfectly overlap anymore.


 
Cheers!!
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?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



From: Martin Sherman <[hidden email]>
To: [hidden email]
Sent: Sun, April 3, 2011 8:08:28 PM
Subject: [SPSSX-L] How to get density scatterplot

Dear Listers;  I am attempting to get a scatter plot that reveals the density at each data point, however, after numerous tries I have been unsuccessful.  Any advice will be appreciated. Thanks,

 

Martin F. Sherman, Ph.D.

Professor of Psychology

Director of  Masters Education in Psychology: Thesis Track

 

Loyola University Maryland

Department of Psychology

222 B Beatty Hall

4501 North Charles Street

Baltimore, MD 21210

 

410-617-2417

[hidden email]

 

Reply | Threaded
Open this post in threaded view
|

Re: How to get density scatterplot

Art Kendall
In reply to this post by msherman
How are you trying to do the scatterplot?  Can you post the syntax?

One way is to use IGRAPH with [Pasted from help.]

SCATTER Subcommand (IGRAPH command)

SCATTER produces two- or three-dimensional scatterplots. Scatterplots can use either categorical or scale dimensions to create color or size legends. Categorical dimensions are required to create style legends.

The keyword COINCIDENT controls the placement of markers that have identical values on all axes. COINCIDENT can have one of the following two values:

NONE Places coincident markers on top of one another. This is the default value.
JITTER Adds a small amount of random noise to all scale axis dimensions. Specifying an amount is no longer supported and is ignored.

Example

IGRAPH
        /Y=VAR(sales96) TYPE=SCALE
        /X1=VAR(sales95) TYPE=SCALE
        /COORDINATE=VERTICAL
        /SCATTER COINCIDENT=JITTER.

• COORDINATE defines the chart as two-dimensional with sales96 on the vertical dimension.

• SCATTER creates a scatterplot of sales96 and sales95.

• The scale axes have random noise added by the JITTER keyword allowing separation of coincident points.

syntax?

Another is to modify the GPL.  [Pasted from help.]

Jittered Categorical Scatterplot (GPL)

GPL for jittered categorical scatterplot
SOURCE: s = userSource(id("Employeedata"))
DATA: jobcat=col(source(s), name("jobcat"), unit.category())
DATA: gender=col(source(s), name("gender"), unit.category())
GUIDE: axis(dim(2), label("Gender"))
GUIDE: axis(dim(1), label("Employment Category"))
ELEMENT: point.jitter(position(jobcat*gender))



Art Kendall
Social Research Consultants

On 4/3/2011 2:08 PM, Martin Sherman wrote:

Dear Listers;  I am attempting to get a scatter plot that reveals the density at each data point, however, after numerous tries I have been unsuccessful.  Any advice will be appreciated. Thanks,

 

Martin F. Sherman, Ph.D.

Professor of Psychology

Director of  Masters Education in Psychology: Thesis Track

 

Loyola University Maryland

Department of Psychology

222 B Beatty Hall

4501 North Charles Street

Baltimore, MD 21210

 

410-617-2417

[hidden email]

 

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

Re: How to get density scatterplot

Jon K Peck
In reply to this post by Albert-Jan Roskam
If you just want collision avoidance, GPL provides several ways to do this.  Look up collision modifier in GPL statements>ELEMENT.
dodge.symmetric: Moves graphic elements next to other graphic elements that appear at the same value, rather than superimposing them.
Dodging example - this is a dot plot:
ELEMENT: point.dodge(position(bin.dot(salary*jobcat)))

Jittering:
joint.normal        Jitter points in all dimensions using a normal distribution
joint.uniform        Jitter points in all dimensions using a uniform distribution
conditional.normal        Jitter points in the analysis dimension using a normal distribution
conditional.uniform        Jitter points in the analysis dimension using a uniform distribution

Jittering example:
ELEMENT: point.jitter(position(jobcat*gender))

You can paste the scatterplot syntax from the Chart Editor and modify as desired.

For suitable data, you could also consider a bubble chart with the n as the bubble size.  You can get that from Graphs>Graphboard Template Chooser.  You would need to run aggregate and save the N in order to use it to scale the bubbles.

HTH,
Jon Peck


Jon Peck
Senior Software Engineer, IBM
[hidden email]
312-651-3435




From:        Albert-Jan Roskam <[hidden email]>
To:        [hidden email]
Date:        04/03/2011 02:17 PM
Subject:        Re: [SPSSX-L] How to get density scatterplot
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




Hi Martin,

Like Jon suggested, you could use 2D bins. You can do that in R with ggplot2:
http://had.co.nz/ggplot2/stat_bin2d.html
Useful for when you have lots of data points (and it has shiny colours --> nice to impress management ;-).

Alternatively, you can use alpha scales to indicate intensity, or add random noise (jitter). The latter can also easily be done in plain syntax, by adding rv.uniform(0,1) or something similar to your data so the data points don't perfectly overlap anymore.


 
Cheers!!
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?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~




From: Martin Sherman <[hidden email]>
To:
[hidden email]
Sent:
Sun, April 3, 2011 8:08:28 PM
Subject:
[SPSSX-L] How to get density scatterplot


Dear Listers;  I am attempting to get a scatter plot that reveals the density at each data point, however, after numerous tries I have been unsuccessful.  Any advice will be appreciated. Thanks,

 

Martin F. Sherman, Ph.D.

Professor of Psychology

Director of  Masters Education in Psychology: Thesis Track

 

Loyola University Maryland

Department of Psychology

222 B Beatty Hall

4501 North Charles Street

Baltimore, MD 21210

 

410-617-2417

msherman@...