[Rd] support for POSIXct classes in image.default axes

Prof Brian Ripley ripley at stats.ox.ac.uk
Wed Apr 17 10:15:57 CEST 2013


On 12/04/2013 12:27, Michael Sumner wrote:
> Hello, I would like to suggest the following change to image.default in
> src\library\graphics\R\image.R:
>
> 98c98
> <       plot(NA, NA, xlim = xlim, ylim = ylim, type = "n", xaxs = xaxs,
> ---
>>        plot(x[1], y[1], xlim = xlim, ylim = ylim, type = "n", xaxs = xaxs,
>

I think xlim, ylim is a better idea: this relies on range() preserving 
the class.

Done now (in R-devel pro tem).

> This provides all the support of axis.POSIXt that plot.default gives,
> currently the default new plot in image.default uses NAs and the axis class
> is ignored. This is nice for plotting time series data stored in a matrix.
>
> Here's a dummy example that shows usage with my change:
>
> data(volcano)
> x <- list(x = Sys.time() + seq(1, 1e6, length = nrow(volcano)), y =
> 1:ncol(volcano), z = volcano)
>
> ## date-time formatting on the x-axis
> image(x)
>
> ## date-time formatting on the y-axis
> image(x$y, x$x, t(x$z))
>
> Without the change we get the very large underlying numeric values for the
> times on the axis.
>
> We can still override the default axis to do a workaround: :
> image(x, axes = FALSE)
> axis.POSIXct(x$x, side = 1)
>
> Cheers, Mike.
>
>
>


-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-devel mailing list