Skip to content

annotation problems (conditional text())

3 messages · Uwe Ligges, Johannes Graumann

#
Hello,

I'm trying to annotate my plots nicely and am running into trouble.
This example contains two problems:
a) the 'text()' arguments do not show the conditional behavior I'm
trying to give them. I try to test for the intercept of my regression
and reformat the output accordingly ('+ intercept' in the >= 0 case and
'- sqrt(intercept^2)' in the other case), which doesn't work this way.
b) my pasted substitute commands yield jolted output, which overwrites
itself ...

Can anyone give this newbie a nudge into the right direction?

Thanks, Joh

if(m >= 0){
  text(
    4,0.19,
    cex=0.75,
    adj=0,
    paste(
      substitute(
        y == m*x+b,
        list(
          m=round(m,digits=5),
          b=round(b,digits=5)
        )
      ),
      "\n",
      substitute(
        R^2==rsquared,
        list(
          rsquared=round(summary(fit)$r.squared,digits=3)
        )
      )
    )
  );
  text(
    4,0.19,
    cex=0.75,
    adj=0,
    paste(
      substitute(
        y == m*x-b,
        list(
          m=round(m,digits=5),
          b=round(sqrt(b^2),digits=5)
        )
      ),
      "\n",
      substitute(
        R^2==rsquared,
        list(
          rsquared=round(summary(fit)$r.squared,digits=3)
        )
      )
    )
  )
}
#
Johannes Graumann wrote:

            
1. Multi-line mathematical annotation is not supported. You have to add 
them line by line.

2. You want to use a construct such as
   if(m >= 0){
     # code for text 1
   } else{
     # code for text 2
   }
rather than the one you speicfied below, which evaluates both text() 
calls if m > 0.

Uwe Ligges
2 days later
#
Thanks! Major knot in brain unraveled ...

Joh

On Sat, 20 Nov 2004 17:43:37 +0100
Uwe Ligges <ligges at statistik.uni-dortmund.de> wrote: