s-news
[Top] [All Lists]

[S] Extension to a simple graphical question

To: S-news@wubios.wustl.edu
Subject: [S] Extension to a simple graphical question
From: R.Verwer@nih.knaw.nl
Date: Thu, 28 Sep 2000 17:07:05 +0200
Organization: Netherlands Institute for Brain Re
Reply-to: R.Verwer@nih.knaw.nl
Sender: owner-s-news@wubios.wustl.edu
Dear All,

I would like to thank Bert Gunter, Andy Liaw, Greg Snow, Leonid Gibiansky and Paul Kristiansen for their prompt reply to my question. Their suggestion was to use the jitter() function, which adds a little random noise to numeric data. I include a few examples provided by Greg Snow:

plot(jitter(x), jitter(y) ) # add noise in both directions
plot(jitter(x), y ) # add only to x, y is exact value
plot(x, jitter(y) ) # and noise to y, x is exact value
plot(jitter(x, factor=2), y) # add more noise
plot(jitter(x, factor=0.1), y) # add very little noise

Or another alternative is to use aggregate and symbols:
> temp <- data.frame( x=c(1,2,3,4,1,2,3,1,2,1), y=c(1,2,3,4,1,3,2,1,1,1) )
> temp2 <- aggregate(rep(1, dim(temp)[1]), list(xx=temp$x,yy=temp$y), sum)
> symbols( temp2$xx, temp2$yy, circles=sqrt(temp2$x), inches=0.3)

However, since the above solutions work for numeric data and eventually convert factors into integers Greg also provided an alternative that works with factors:


temp <- data.frame( x=letters[c(1,2,3,4,1,2,3,1,2,1)],
y=c(1,2,3,4,1,3,2,1,1,1) )
temp2 <- aggregate(rep(1, dim(temp)[1]), list(xx=temp$x,yy=temp$y), sum)
symbols( temp2$xx, temp2$yy, circles=sqrt(temp2$x), inches=0.3,xaxt="n")
temp3 <- levels(temp2$xx)
axis(1, at=seq(along=temp3), labels=temp3)

the symbols function automatically converts factors to integers (if you
want to do so by hand then replace temp2$xx with codes(temp2$xx) ). The
xaxt="n" tells it not to put anything on the x axis (it would default to
numbers), then the axis command fills in the axis with the factor levels.

Something similar could be done with the jitter examples also.

Thank you again.

Ronald


On Wed, 27 Sep 2000 wrote:

>
> Dear All,
>
> I would like to follow up on a question posed by Reid Giliam
> at 19 Sept 2000. In the graphs two coinciding data points were
> plotted next to each other. In my experience those points are
> plotted on top of each other. Is there an easy solution to get them
> plotted as indicated in Reid Giliam's graph?
>
> I am using SPLUS 2000, v 2
>
>
> Thanks in advance
>



Ronald W.H. Verwer
Netherlands Institute for Brain Research
Meibergdreef 33, 1105 AZ Amsterdam
The Netherlands
tel: +31 (20) 5665518
fax: +31 (20) 6961006
e-mail: r.verwer@nih.knaw.nl
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu.  To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message:  unsubscribe s-news





<Prev in Thread] Current Thread [Next in Thread>
  • [S] Extension to a simple graphical question, R . Verwer <=