[R] axis() after image.plot() does not work except if points() is inserted between

Marc Girondot marc_grt at yahoo.fr
Fri Jul 21 16:05:41 CEST 2017


It is known (several discussions on internet) that axis() cannot be used 
after fields:::image.plot() (axis() shows nothing).

However, if points(1.5, 1.5, type="p") is inserted before the axis() 
finctions, it works.

I have investigated what points(1.5, 1.5, type="p") is doing to allow 
axis to work and I don't find a solution. par() options are identical 
(p1 and p2 are identical).

Has someone a solution ?

Thanks

Marc

library(fields)
p0 <- par(no.readonly=TRUE)
image.plot(D, col=rev(heat.colors(128)),bty="n", xlab="Lines",
            ylab="Columns", cex.lab = 0.5, zlim=c(min(D, 
na.rm=TRUE),max(D, na.rm=TRUE)),
            las=1, axes=FALSE)
p1 <- par(no.readonly=TRUE)

# if you remove this points() function, axis will show nothing.

points(1.5, 1.5, type="p")
p2 <- par(no.readonly=TRUE)

##########
axis(1, at=seq(from=0, to=1, length=nrow(D)), labels=0:2, cex.axis=0.5)
axis(2, at=seq(from=0, to=1, length=ncol(D)), labels=0:3, las=1, 
cex.axis=0.5)

identical(p1, p2)



More information about the R-help mailing list