Skip to content
Prev 273599 / 398506 Next

Titles changing when a plot is redrawn

Thank you for telling me a fix.  

But I still don't know if this behavior is what is intended.  I used bquote(...) because the plotmath(...) help page refers to bquote and gives an example like this.  I suspect most users will be baffled by this kind of behavior, especially since it does not occur when there is one plot.  By this I mean that I can draw one plot and title it with the same string using bquote( ).  If I change the value of i, and redraw the graph, the redrawn graph has the original value of i in the title, not the updated value. So in this case, an unevaluated expression is not re-evaluated at draw time?

John 


-----xieyihui at gmail.com wrote: -----
To: John Nolan <jpnolan at american.edu>
From: Yihui Xie 
Sent by: xieyihui at gmail.com
Date: 10/05/2011 11:49PM
Cc: r-help at r-project.org
Subject: Re: [R] Titles changing when a plot is redrawn

I think the problem is your str1 is an unevaluated expression and will
change with the value of i. You should be able to get a fixed title by
this:

par(mfrow = c(2, 1))
for (i in 1:2) {
    x <- 1:100
    rmse <- sin(x/5)  # fake data
    plot(x, rmse, main = substitute(list(RMSE(theta), i == z), list(z = i)))
}

Regards,
Yihui
--
Yihui Xie <xieyihui at gmail.com>
Phone: 515-294-2465 Web: http://yihui.name
Department of Statistics, Iowa State University
2215 Snedecor Hall, Ames, IA
On Wed, Oct 5, 2011 at 10:01 PM, John Nolan <jpnolan at american.edu> wrote: