If you draw directly using the RasterLayer method for the graph, there is no problem with resizing.
#
Thus, it must be something in the original plot call before the .imageplot method is .imageplot .
showMethods("plot", classes = "RasterLayer", includeDefs = TRUE)
This happens if we call raster:::.plotraster directly, and this is the function that calls raster:::.imageplot :
raster:::.plotraster(shrunk, col = rev(terrain.colors(255)), maxpixels = 5e+05) points(shrunk.coords, pch = ".")
These are actually labels on the axis, not the image itself. Look at this, this is true for resizing:
raster:::.imageplot(shrunk) abline(h = c(-80, 80), v = c(-80, 80))
But do it like this, and the lines will no longer be at [-80, 80] after resizing:
plot(shrunk) abline(h = c(-80, 80), v = c(-80, 80))
Thus, these are actually the points constructed after the raster is not displayed correctly: the graph method preserves the aspect ratio, therefore the expansion of the graph does not “stretch” the raster circle to an ellipse. But it does something for the points that are added after that, so par() calls should not be handled correctly (perhaps in raster:::.imageplot ).
Another way to see the problem is to show that axis () does not know the space used by the graph, which is the same problem that you see when rewriting:
plot(shrunk) axis(1, pos = 1)
When you resize the x axis, the two axes no longer synchronize.