[R] Plotting on log scale using plot.date()
Uwe Ligges
ligges at statistik.uni-dortmund.de
Thu Feb 7 22:01:35 CET 2002
Roger Peng wrote:
>
> 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:
>
> > library(date)
> > x <- as.date(1:100)
> > y <- 1:100
> > plot(x, y, log = "y")
> Warning message:
> parameter "log" couldn't be set in high-level plot() function
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.
> 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?
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list