Thanks Duncan for the speedy response. I should have realized that the negative value was adversely affecting the expression. I'll do some further reading on plotmath. Michael
________________________________ From: Duncan Murdoch [mailto:[EMAIL PROTECTED] Sent: Mon 24/09/2007 3:32 PM To: Folkes, Michael Cc: [EMAIL PROTECTED] Subject: Re: [R] parse in text function of plots, confusing behaviour On 24/09/2007 5:55 PM, Folkes, Michael wrote: > HI all, > I'm failing to understand why the following is happening. > In this plot I rely on two text functions both using parse. The second one > works properly by writing a gamma symbol 5 times, the first one only works > properly four times. The only difference is that I add a string to the paste > function of that which does work properly. Why does it behave like this? > thanks so much! > Michael Folkes > > > plot(1,1,type='n',ylim=c(-2,2)) > for(gam in seq(-1,.25,length=5)){ > #doesn't repeat gamma symbol properly > text(.8,gam,parse(text=paste("gamma",gam,sep='')),cex=.75,adj=0) > > # however this works if an additional string is included in the paste function > text(1,gam,parse(text=paste("gamma","~hi",gam,sep='')),cex=.75,adj=0) > } Take a look at what you're trying to plot: > for (gam in seq(-1, 0.25, length=5)) { + print(parse(text=paste("gamma",gam,sep=''))) + } expression(gamma-1) attr(,"srcfile") <text> expression(gamma-0.6875) attr(,"srcfile") <text> expression(gamma-0.375) attr(,"srcfile") <text> expression(gamma-0.0625) attr(,"srcfile") <text> expression(gamma0.25) attr(,"srcfile") <text> In the first 4 cases, it's "gamma - value", while the last one is "gammavalue". You probably want something like the bquote example on the ?plotmath page, e.g. > for (gam in seq(-1, 0.25, length=5)) { + text(1, gam, bquote(paste(gamma," ",.(gam)))) + } Duncan Murdoch [[alternative HTML version deleted]] ______________________________________________ R-help@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.