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

Bert Gunter gunter.berton at gene.com
Thu Jan 13 18:01:05 CET 2011


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 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
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Bert Gunter
Genentech Nonclinical Biostatistics
467-7374
http://devo.gene.com/groups/devo/depts/ncb/home.shtml



More information about the R-help mailing list