Skip to content

Plotting on log scale using plot.date()

2 messages · Roger D. Peng, Uwe Ligges

#
Hi, I'm trying to use the date library and I think I'm getting an
incorrect warning when I make a plot with plot.date().  For example:
Warning message: 
parameter "log" couldn't be set in high-level plot() function 

The problem appears to be in the last line of plot.date() function where
the x-axis is being created.  There is a call to axis() and the log = "y"
parameter is being passed.

I noticed a similar-sounding bug in the bugs repository (#1235) but I
don't think it's related. 

Here's the code for plot.date().  I think problem is at the end.

plot.date
function (x, y, ..., axes, xaxt, xlab, ylab, xlim = range(x, 
    na.rm = TRUE), ylim = range(y, na.rm = TRUE)) 
{
    [ ... some code ... ]
    else {
        plot(x, y, ..., xaxt = "n", xlab = xlab, ylab = ylab, 
            xlim = xlim, ylim = ylim)
        x <- c(x[!is.na(x)], xlim)
        xd <- date.mdy(x)
        temp <- pretty(x, n = par("lab")[1])
        delta <- temp[2] - temp[1]
        if (delta < 1) 
            temp <- seq(min(x), max(x), 1)
        else if (delta > 182) {
            temp <- xd$year + (x - mdy.date(1, 1, xd$year))/365
            temp <- pretty(temp, n = par("lab")[1])
            temp <- mdy.date(1, 1, floor(temp)) + floor((temp%%1) * 
                365)
        }
        axis(1, temp, as.character.date(temp), ...)
    }
}

Should ... be passed to axis?

Thanks!


platform i686-pc-linux-gnu
arch     i686             
os       linux-gnu        
system   i686, linux-gnu  
status                    
major    1                
minor    4.1              
year     2002             
month    01               
day      30               
language R              

-roger
_______________________________
UCLA Department of Statistics
rpeng at stat.ucla.edu
http://www.stat.ucla.edu/~rpeng

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
Roger Peng wrote:
It is a warning message, not an error message.
In this particular case the warning message can be ignored, because the
resulting plot is exactly looking as expected.
Yes, it should. One example that it is useful: 
  plot(x, y, log = "y", cex.axis=2)


Uwe Ligges
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._