Skip to content

2d plot with modification of plotting symbol to indicate third dimension.

6 messages · John Sorkin, Duncan Murdoch, Bert Gunter +3 more

#
I would like to plot 3-dimensional data on a two-dimensional scatter-plot.
Is there a way I can automatically modify the plot symbol (e.g. changing size or color) to indicate the value of a third variable? E.g. How can I plot weight vs. age and indicate the value of muscle mass for each value weight-age pair by making the plot point proportional to the subject's muscle mass?
Thanks,
John


John David Sorkin M.D., Ph.D.
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing)

Confidentiality Statement:
This email message, including any attachments, is for th...{{dropped:6}}
#
On 11-01-12 9:33 PM, John Sorkin wrote:
> I would like to plot 3-dimensional data on a two-dimensional 
scatter-plot.
 > Is there a way I can automatically modify the plot symbol (e.g. 
changing size or color) to indicate the value of a third variable? E.g. 
How can I plot weight vs. age and indicate the value of muscle mass for 
each value weight-age pair by making the plot point proportional to the 
subject's muscle mass?

Just set cex to the other variable.  For example,

plot(1:10, 1:10, cex=1:10)

Similarly, col and pch can be set to vector values, which are recycled 
through the points.

Duncan Murdoch
#
Duncan:

I must humbly disagree. Here's the problem: in order to accurately
represent the value, the "point" = circle _area_ must be proportional
to the value. That is, the eye "sees" the areas, not the radii, as the
point "size." A delightful reference on this is Howard Wainer's 1982
or so (can't remember exactly) article in THE AMERICAN STATISTICIAN,
"How to Graph Data Badly" (or maybe "Plot" Data).

Anyway, using cex, I have no idea whether a point drawn with cex =
1.23 is 1.23 times the area or radius -- or neither -- of a point
drawn with cex =1. Indeed, it might vary depending on the
implementation/OS/graphics fonts.  So it seems better to me to "draw"
the point with symbols(), where you can have complete control over the
size.

Obviously, let me know if I'm wrong about this.

Cheers,
Bert

On Wed, Jan 12, 2011 at 9:11 PM, Duncan Murdoch
<murdoch.duncan at gmail.com> wrote:

  
    
#
On Wed, Jan 12, 2011 at 9:33 PM, John Sorkin
<jsorkin at grecc.umaryland.edu> wrote:
Check out:
http://flowingdata.com/2010/11/23/how-to-make-bubble-charts/
#
On Thu, 13 Jan 2011, Bert Gunter wrote:

            
('Display' Data, 1984).

In a pseudo-3D plot, such as scatter3dplot, size perception can be 
even more complex.
It will be approximately 1.23 times the radius.  For the default pch=1 
(and we seem to be talking about circles), in the graphics devices 
points() and symbols() will call the same graphics primitives for 
circles.  Now circles will have their sizes rounded to something, 
maybe the nearest pixel, maybe 0.01bp, maybe something else, so you 
may not have much control over very small circles, but you will over 
those of diameter about 5mm or more.
In some ways this goes back to S, where AFAIR (and ?points suggest) 
pch=1 was an octagon and symbols() was the only way to draw circles.

  
    
#
have you taken a look at the hexbin package? 'cex' , 'pch' & 'col' will let you make the changes

Sent from my iPad
On Jan 12, 2011, at 21:33, "John Sorkin" <jsorkin at grecc.umaryland.edu> wrote: