Hi,

I need a custom axis function for a plot, but it seems
that current.panel.limits() sometimes returns NaN limits for the plot, which
it much harder to calculate anything sensible.
An illustration:

Given this axis function:


vs.axis <- function(...){
   xlim <- current.panel.limits()$xlim
   ylim <- current.panel.limits()$ylim

   # Debug code
   print(list(ylim=ylim,xlim=xlim))

   xat <- pretty(seq(xlim[1],xlim[2],100),n=5)
   yat <- pretty(seq(ylim[1],ylim[2],100),n=4)
   xlab <- sub("-","",as.character(xat))
   ylab <- sub("-","",as.character(yat))
   panel.axis(side="top",at=xat,labels=xlab)
   panel.axis(side="right",at=yat,labels=ylab)
}

and the attached data set, I get this output:

> xyplot(F1 ~F2,data=pb,axis=vs.axis)
$ylim
[1] NaN NaN

$xlim
[1]  346.5 3823.5

Error in if (del == 0 && to == 0) return(to) :
  missing value where TRUE/FALSE needed

What's wrong? Is there a more robust way of getting the x- and y- limits?

/Fredrik

-- 
"Life is like a trumpet - if you don't put anything into it, you don't get
anything out of it."
______________________________________________
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.

Reply via email to