[Rd] axis.POSIXct and axis.Date fail for reversed axes

William May williamcmay at live.com
Fri Aug 19 00:06:36 CEST 2016


When plotting a reversed time axis with the base graphics system, R 
fails to label the axes.

Example:

times <- c(Sys.time() - 100, Sys.time())
plot(times, 1:2, xlim = times) # correctly labels the x-axis
plot(times, 1:2, xlim = rev(times)) # fails to label the x-axis
axis.POSIXct(1, times) # still fails to add labels

dates <- c(Sys.Date() - 10, Sys.Date())
plot(dates, 1:2, xlim = dates) # correctly labels the x-axis
plot(dates, 1:2, xlim = rev(dates)) # fails to label the x-axis
axis.Date(1, dates) # still fails to add labels

This is clearly due to the variable keep in both axis functions.

keep <- z >= range[1L] & z <= range[2L]

But if the axis is reversed that should be:

keep <- z <= range[1L] & z >= range[2L]



More information about the R-devel mailing list