[R] Adding text to a plot

Joerg Maeder maeder at atmos.umnw.ethz.ch
Wed Jul 3 16:30:39 CEST 2002


Hello Patrick

you can use special chars inside your string. For a linefeed you need
'\n'
c <- paste(a,b,sep='\n')
text(90, max((k[,2])-0.51), c)

gruess

joerg

Patrick Hausmann wrote:
> 
> Dear R-users,
> 
> again two question...
> 
> # Question 1
> Adding two lines of text to a plot, I am using:
> 
> # -------------------------------
> plot(k[,1], k[,2], pch=16,
>     ylim=range((min(k[,2])-0.2):(max(k[,2])+1)))
> 
> a <- paste("Cor.:" ,cor(k[,2],k[,1]))
> b <- paste(nrow(k), "Countries")
> 
> text(90, max((k[,2])-0.51), a)
> text(90, max((k[,2])-0.83), b)
> # -------------------------------
> But the distance between the first and second line depends on the
> scale of the y-axis.
> 
> Is there a solution to put the lines in the upper right corner,
> independent of the y-scale?
> 
> # Question 2
> My data.frame looks like:
> > u
>       country     gdp50     w5073
> 1.AUS  AUS     77.15967   2.1708460
> 1.AUT  AUT     74.06830   1.8691745
> 1.BEL  BEL     77.87497   1.7547546
> 1.CAN  CAN     87.07300   1.3649655
> [...]
> 
> To add labels on points in a plot I call:
> text(x=u[,2]+chw, y=u[,3], labels=levels(u[,1]), adj=0 )
> 
> How can I label only the datapoints for 'CAN' and 'AUS'?
> 
> Thanks for any help
> Patrick
> -------------
> Patrick Hausmann
> Friedrich-Wilhelm Str. 37 - D-28199 Bremen
> Tel. +49 421 5980631 - Fax. +49 421 5980632
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> 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
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

-- 
Joerg Maeder    .:|:||:..:.||.::   maeder at atmos.umnw.ethz.ch
Tel: +41 1 633 36 25   .:|:||:..:.||.::   
http://www.iac.ethz.ch/staff/maeder
PhD student at INSTITUTE FOR ATMOSPHERIC AND CLIMATE SCIENCE (IACETH)
ETH ZÜRICH Switzerland
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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