(Why is this an R-devel topic?)

When you resize a plot (and sometimes when the graph is repainted), the display list is replay-ed. So if you force delayed evaluation, you get evaluation when the list is replay-ed. So the 'strange' thing is that you think delaying evaluation is a good idea. Use substitute, as the R help pages advise. E.g.

par(mfrow = c(1,3))
for (i in 1:3){
  title <- substitute(gamma[j], list(j=i))
  plot(1:10, main = title)
}


On 24/11/2011 08:54, Mathieu Ribatet wrote:
Dear list,

I found a strange behavior of the graphic display when using bquote to set a 
title to a plot. The problem arise when you manually resize the graphic window 
using the mouse. It happens on both quartz and x11 devices. Here's a 
reproducible example:

par(mfrow = c(1,3))
for (i in 1:3){
   title<- as.expression(bquote(gamma[.(i)]))
   plot(1:10, main = title)
}

Once you ran the code, the figure displays as expected --- each title is 
$\gamma_i$, $i=1, 2, 3$. Now if you resize manually the graphic window using 
the mouse all the titles will be set to $\gamma_3$.

In case this is useful, here's the ouput of sessionInfo().

sessionInfo()
R version 2.14.0 (2011-10-31)
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)

locale:
[1] C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

Best,
Mathieu

-----------------------------------------------------------------
I3M, UMR CNRS 5149
Universite Montpellier II,
4 place Eugene Bataillon
34095 Montpellier cedex 5   France
http://www.math.univ-montp2.fr/~ribatet
Tel: + 33 (0)4 67 14 41 98

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


--
Brian D. Ripley,                  rip...@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to