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

jim holtman jholtman at gmail.com
Wed Apr 8 18:23:38 CEST 2009


Use 'text' to write out each one:

plot(0, type='n', xlim=c(0,1), ylim=c(0,1))
text(seq(0,1,length=10), rep(0.5,10), LETTERS[1:10], col=1:10)



On Wed, Apr 8, 2009 at 12:15 PM, Daren Tan <darentan76 at gmail.com> wrote:
> 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"))
>
> ______________________________________________
> R-help at r-project.org 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.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?




More information about the R-help mailing list