[R] log error for use on axis

Vikneswaran Gopal viknesh at stat.ufl.edu
Fri Jul 17 19:31:07 CEST 2009


NDC/jshipman wrote:
> Hi,
>     I am new to R plot.  I am trying to scale my y axis in log.  When I 
> do this I receive the following error
> 
> Error in axis(side = side, at = at, labels = labels, ...) :
>   CreateAtVector [log-axis()]: axp[0] = 0 < 0!
> In addition: Warning messages:
> 1: In plot.window(...) :
>   nonfinite axis limits [GScale(-inf,1.31772,2, .); log=1]
> 2: In axis(side = side, at = at, labels = labels, ...) :
>   CreateAtVector "log"(from axis()): axp[0] = 0 !
> 
> 
> My code is as follows:
> 
> foundOr <- read.table("yahoos_f.txt", sep="," , header=T)
> if (max(foundOr$s_) >= max(notFoundOr$s_)) maxY = log(max(foundOr$s_)) 
> else maxY = log(max(notFoundOr$s_))
> jpeg('clusterYS_.jpg', quality = 100, bg = "white", res = 200, width = 
> 2000, height = 2000 )
> plot(foundOr$uid, foundOr$s_, xlab="uid", ylab="Log Search Results",  
> main="uid vs Search", pch=20, col="blue", log = "y", xlim=c(0,300), 
> ylim=c(0,maxY))
> dev.off()
> 
> If I remove the log = "y" everything works fine.  Am I using the log 
> call incorrectly?  Any help would be appreciated.
> 
> 

It appears that we cannot set ylim if log="y" is also set. This works:

 > foundOr <- read.table("yahoos_f.txt", sep="," , header=T)
 > plot(foundOr$uid, foundOr$s_, xlab="uid", ylab="Log Search Results", 
  main="uid vs Search", pch=20, col="blue", log = "y", xlim=c(0,300))

but not this:

 > plot(foundOr$uid, foundOr$s_, xlab="uid", ylab="Log Search Results", 
  main="uid vs Search", pch=20, col="blue", log = "y", xlim=c(0,300), 
ylim=c(0,200))

Again, this works:

 > plot(foundOr$uid, foundOr$s_, xlab="uid", ylab="Log Search Results", 
  main="uid vs Search", pch=20, col="blue", log = "xy")

but not this:

 > plot(foundOr$uid, foundOr$s_, xlab="uid", ylab="Log Search Results", 
  main="uid vs Search", pch=20, col="blue", log = "xy", xlim=c(0,3000))

 From traceback(), the crash occurs in the .Internal() part of axis(). I 
am not sure why this occurs either.

Vik




More information about the R-help mailing list