I set up a nice plot with a transparent superimposed scatterplot on a png image file. I want my plot window and my pdf output to be of the exact same size as my png- 962×745.
However, even after turning off axes, annotations and frames, R still leaves a border around the image.
This can be shown with an easy example: This plot shows two dots, which should be at the outermost ends of the plot. But they aren’t:
plot(rbind(c(1,745),c(962,1)),bty ="n",axes=F,frame.plot=F, xaxt='n', ann=FALSE, yaxt='n', asp=745/962)
And together with the PDF device:
pdf(width=10.02,height=7.76)
par(mar=rep(0, 4),mai=rep(0, 4), xpd = NA)
plot(rbind(c(1,745),c(962,1)),bty ="n",axes=F,frame.plot=F, xaxt='n', ann=FALSE, yaxt='n', asp=745/962)
dev.off()
You could also use
gridgraphics to avoid those default axes, etc.