[R] Point labels
Gavin Simpson
gavin.simpson at ucl.ac.uk
Wed May 22 11:16:48 CEST 2002
There is a very simple and nice example of how to go about producing
this result in John Maindonald's "Using R for data analysis and
graphics", found at:
http://cran.r-project.org/doc/contrib/usingR.pdf
Section 3.3 Adding points lines and text would seem to be what you are
after, including how to get the 1 character offsets for the label of
each point.
The example goes as follows, using files from JM's home page (there is
link to it from http://cran.r-project.org/other-docs.html )
> attach(primates)
> plot(x=Bodywt, y=Brainwt, pch=16, xlab="Body weight (kg)",
ylab="Brain weight (g)",xlim=c(5,240), ylim=c(0,1500))
> chw < <- par()$cxy[1]
> text(x=Bodywt+chw, y=Brainwt, labels=row.names(primates), adj=0)
Which places labels to the right of the plotted points.
Substitute your variables and row.names/vector of labels for the ones
used above, but I'd recommend downloading JM's guide as it is a very
good introduction to all things R.
All the best
Gavin Simpson
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
Gavin Simpson [T] +44 (0)20 7679 5402
ENSIS Research Fellow [F] +44 (0)20 7679 7565
ENSIS Ltd. & ECRC [E] gavin.simpson at ucl.ac.uk
UCL Department of Geography [W] http://www.ucl.ac.uk/~ucfagls/cv/
26 Bedford Way [W] http://www.ucl.ac.uk/~ucfagls/
London. WC1H 0AP.
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
-----Original Message-----
From: owner-r-help at stat.math.ethz.ch
[mailto:owner-r-help at stat.math.ethz.ch] On Behalf Of Daniel Mastropietro
Sent: 21 May 2002 22:32
To: r-help at stat.math.ethz.ch
Subject: [R] Point labels
Hello,
Is there an option I can easily set to put labels next to the points in
a
simple plot?
The closest I got to it was to use the option pch, but this replaces the
point symbol with the character specified, and it is not what I want.
Thanks
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
-.-.-.-
r-help mailing list -- Read
http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._.
_._._._
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list