Sometimes, R draws white lines across an image plot for no apparent reason. Other plotting commands like lines() or contour() are not affected. This example is with x11, but it has happened with png() as well.
It can be fixed by changing the figure geometry. For example, a vertical white line can be eliminated by changing the width of the plot. But, this is not a real solution to the problem: many of my codes need to create publication-quality figures in scripts without supervision, often in packages I distribute to others.
Has anyone else encountered this? Does anyone know how to fix it? I'm using Ubuntu 16.04 64-bit with R version 3.3.1 (2016-06-21) -- "Bug in Your Hair", but have had this problem for years with many versions of R.
Here's an example code and image.
x = 4 * 0:1250
y = 4 * 0:1325
Z = matrix(rnorm(1251*1326), 1251)
image(x, y, Z)
Try setting the logical useRaster
option within the image function. As in:
x = 4 * 0:1250
y = 4 * 0:1325
Z = matrix(rnorm(1251*1326), 1251)
image(x, y, Z, useRaster = TRUE)
According to the details within ?image(),
Images for large ‘z’ on a regular grid are rendered more efficiently with 'useRaster = TRUE’ and can prevent rare anti-aliasing artifacts
See the man page for the full description.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With