is there a way to hide/undraw mtext (or lines etc.) in a loop like
plot(runif(10))
iterCol <- rainbowPalette(10)
for(i in 1:10){
mtext(paste("this is iteration ", i, sep=""))
points(runif(10),col=iterCol[i])
Sys.sleep(1)
## UNDRAW/HIDE the text so that it does not mess up the plot in the next
iteration
}
--
View this message in context: http://r.789695.n4.nabble.com/HOW-TO-REMOVE-MTEXT-FROM-PLOT-plotting-changing-populations-with-titles-in-loop-tp3981757p3981757.html
Sent from the R help mailing list archive at Nabble.com.
HOW TO REMOVE MTEXT FROM PLOT, plotting changing populations with titles in loop
3 messages · prinzOfNorway, Sarah Goslee, Uwe Ligges
It's not perfect, but you could use:
mtext(paste("this is iteration ", i, sep=""), col="white")
to overwrite it, or polygon() to draw a white rectangle over the text each time.
Sarah
On Wed, Nov 2, 2011 at 3:15 PM, prinzOfNorway <torgrimsby at gmail.com> wrote:
is there a way to hide/undraw mtext (or lines etc.) in a loop like
plot(runif(10))
iterCol <- rainbowPalette(10)
for(i in 1:10){
mtext(paste("this is iteration ", i, sep=""))
points(runif(10),col=iterCol[i])
Sys.sleep(1)
## UNDRAW/HIDE the text so that it does not mess up the plot in the next
iteration
}
Sarah Goslee http://www.functionaldiversity.org
On 02.11.2011 20:29, Sarah Goslee wrote:
It's not perfect, but you could use:
mtext(paste("this is iteration ", i, sep=""), col="white")
to overwrite it, or polygon() to draw a white rectangle over the text each time.
The question is if it is not better to do the whole plot again and just add the one text in the end. At least if you want to plot into non screen device: You end up with ll those layers of text in the output that makes it larger and additionally slows down the rendering of the whole plot. Uwe Ligges
Sarah On Wed, Nov 2, 2011 at 3:15 PM, prinzOfNorway<torgrimsby at gmail.com> wrote:
is there a way to hide/undraw mtext (or lines etc.) in a loop like
plot(runif(10))
iterCol<- rainbowPalette(10)
for(i in 1:10){
mtext(paste("this is iteration ", i, sep=""))
points(runif(10),col=iterCol[i])
Sys.sleep(1)
## UNDRAW/HIDE the text so that it does not mess up the plot in the next
iteration
}