Hi
For your example
sel <- c(1,4, 9, 11)
text(B, C, A, col= c("black", "red")[(A %in% A[sel])+1])
gives you required colouring.Not sure if it works with basicPlotteR.
Cheers
Petr
-----Original Message-----
From: R-help <r-help-bounces at r-project.org> On Behalf Of varin sacha
via R-help
Sent: Wednesday, May 19, 2021 3:14 PM
To: r-help at r-project.org
Subject: [R] Plot with some countries in red
Dear R-experts,
Here below a toy R code example. I would like some countries (not all of them)
"Italy", "Canada", "Greece" and "Norway"
to appear in red color. The others remaining black. How can I do that without
big changes in my R code ? Indeed, I would like my R code to remain like this as
much as possible, for example, end of my R code, I want to keep the
non-overlapping text label.
############
A<-c("Italy","Germany","USA","Canada","Turkey","Chile","Mexico","Japan","Norway","Finland","Greece")
B<-c(540,523,589,600,499,567,485,467,543,511,500)
C<-c(470,470,489,492,476,475,455,444,489,456,478)
mod1=loess(C~B,span=0.7)
Bfit=seq(from=min(C),to=max(C),length.out=100)
Afit1=predict(mod1,newdata=Bfit)
plot(B,C,main="Courbe de r?gression non param?trique entre ISQ 2015 et ISQ
2018", xlab="score ISQ 2015", ylab="score ISQ 2018
",type="n")
points(Bfit,Afit1,type="l",lwd=2,col="red")
library(basicPlotteR)
# Add non-overlapping text labels
addTextLabels(B, C, A, col.label="black")
############
______________________________________________
R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.
Osobn? ?daje: Informace o zpracov?n? a ochran? osobn?ch ?daj? obchodn?ch
partner? PRECHEZA a.s. jsou zve?ejn?ny na:
https://www.precheza.cz/zasady-ochrany-osobnich-udaju/ | Information about
processing and protection of business partner?s personal data are available on
website: https://www.precheza.cz/en/personal-data-protection-principles/
D?v?rnost: Tento e-mail a jak?koliv k n?mu p?ipojen? dokumenty jsou d?v?rn? a
podl?haj? tomuto pr?vn? z?vazn?mu prohl??en? o vylou?en? odpov?dnosti:
https://www.precheza.cz/01-dovetek/ | This email and any documents attached to
it may be confidential and are subject to the legally binding disclaimer:
https://www.precheza.cz/en/01-disclaimer/