[R] How to add characters on graph ?
Petr Pikal
petr.pikal at precheza.cz
Wed Jan 3 13:45:21 CET 2007
Hi
On 3 Jan 2007 at 12:54, Jenny persson wrote:
Date sent: Wed, 3 Jan 2007 12:54:50 +0100 (CET)
From: Jenny persson <jenny197806 at yahoo.se>
To: r-help at stat.math.ethz.ch
Subject: [R] How to add characters on graph ?
> Dear R-users,
>
> I have following data
>
>
> # Plot coloured scatter plot
>
> c<-dat[100:110,c(5,7,8)]
>
> par(mfrow=c(3,2))
> plot(c$lb,c$index, pch=1, col=5,cex=1, lwd=2,
> xlab="LB", ylab="Index",cex.main =1,font.main= 1,
> main="scatterplot")
>
> ID index lb
> 100 FLINDYTHNIPLI 1.84770221 9.087463
> 101 none 0.06657547 8.927778
> 102 GDDKVYSANGFTT -0.22922544 8.599913
> 103 GDFTQGPQSAKTR 0.01203925 8.483816
> 104 GDKEFSDALGYLQ -0.06264494 8.463524
> 105 GDPTETLRQCFDD -0.10011148 8.483816
> 106 GDSGGSFQNGHAQ -0.13460447 8.442943
> 107 GDVYSFAIIMQEV 1.91504700 8.413628
> 108 GLRSLYPPPPPPQ -0.11224126 8.383704
> 109 GLWVTYKAQDAKT 0.03723291 8.257388
> 110 GMSQPLLDRTVPD -0.06580206 8.294621
>
> When I plotted a scatter plot of index against lb, there are two
> extreme values. How can I plot so that these values are replaced by
> their ID or the IDs are next to these values on the graph? I want to
> do something like: if index > 1.5 then plot the IDs instead of the
> indexes greater than 1.5 or place the Ids next to their indexes. The
I would use such construction
plot(x,y, ..., type="n")
points(x,y, pch=c(NA,1)[(index>1.5)+1])
sel<-(index>1.5)
text(x[sel],y[sel], ID[sel])
see ?points, ?text, ?plot
HTH
Petr
> data above is a little part of my real data (which might have more
> than two extreme outliers).
>
> Thanks for your help,
>
> Jenny
>
> __________________________________________________
>
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch 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.
Petr Pikal
petr.pikal at precheza.cz
More information about the R-help
mailing list