[R] Colour each letter of a text string in a plot

Daren Tan darentan76 at gmail.com
Wed Apr 8 18:15:02 CEST 2009


I am inserting a DNA sequence into a plot, and hope to colourize each
of the four nucleotide of the DNA sequence with a unique colour i.e.,
A ("red"), C ("green"), G ("blue", and T ("yellow"). I use the
following codes, but the DNA sequence only shows as "red"


DNA <- "ACGT"

plot(1, xlim = c(0,1), ylim = c(0,1), axes=F, xlab="", ylab="",
main="", xaxs="i", yaxs="i")

text(x=0.5, y=0.5, labels=DNA, col=c("red", "green", "blue", "yellow"))




More information about the R-help mailing list